From af2624af37a991961fe5b4089c10dd704b34273f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 7 May 2013 00:09:59 +0000 Subject: make mog_fd_get static, favor mog_fd_init mog_fd_init enforces setting the correct type, so relegate mog_fd_get to private usage inside fdmap.c --- cmogstored.h | 1 - fdmap.c | 2 +- test/chunk-parser-1.c | 3 +-- test/fdmap-1.c | 4 ++-- test/queue-idle-1.c | 3 +-- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/cmogstored.h b/cmogstored.h index c958a87..ee6a6fa 100644 --- a/cmogstored.h +++ b/cmogstored.h @@ -287,7 +287,6 @@ struct mog_fd { struct mog_svc *svc; } as; }; -struct mog_fd *mog_fd_get(int fd); void mog_fd_put(struct mog_fd *mfd); void mog_fdmap_requeue(struct mog_queue *quit_queue); size_t mog_fdmap_expire(uint32_t sec); diff --git a/fdmap.c b/fdmap.c index c59157f..8cb9954 100644 --- a/fdmap.c +++ b/fdmap.c @@ -115,7 +115,7 @@ MOG_NOINLINE static struct mog_fd * grow_ref(size_t fd) * Look up a mog_fd structure based on fd. This means memory is reused * by us just as FDs are reused by the kernel. */ -struct mog_fd *mog_fd_get(int fd) +static struct mog_fd *mog_fd_get(int fd) { assert(fd >= 0 && "FD is negative"); if (MOG_LIKELY(fd < mog_sync_fetch(&max_fd))) diff --git a/test/chunk-parser-1.c b/test/chunk-parser-1.c index 335a39b..d9d2b5d 100644 --- a/test/chunk-parser-1.c +++ b/test/chunk-parser-1.c @@ -29,8 +29,7 @@ static void buf_set(const char *s) assert(tmpfp != NULL && "tmpfile(3) failed"); tmpfd = fileno(tmpfp); assert(tmpfd >= 0 && "invalid fd"); - http->forward = mog_fd_get(tmpfd); - http->forward->fd = tmpfd; + http->forward = mog_fd_init(tmpfd, MOG_FD_TYPE_FILE); file = &http->forward->as.file; file->foff = 0; buf = xstrdup(s); diff --git a/test/fdmap-1.c b/test/fdmap-1.c index de30545..d4176f0 100644 --- a/test/fdmap-1.c +++ b/test/fdmap-1.c @@ -10,7 +10,7 @@ int main(void) int open_max = (int)sysconf(_SC_OPEN_MAX); int i; - mfd = mog_fd_get(0); + mfd = mog_fd_init(0, MOG_FD_TYPE_UNUSED); { struct mog_mgmt *mgmt = &mfd->as.mgmt; @@ -18,7 +18,7 @@ int main(void) } for (i = 0; i < open_max; i++) { - mfd = mog_fd_get(i); + mfd = mog_fd_init(i, MOG_FD_TYPE_UNUSED); assert(mfd && "mfd unset"); } diff --git a/test/queue-idle-1.c b/test/queue-idle-1.c index 5d592c1..c5e4f73 100644 --- a/test/queue-idle-1.c +++ b/test/queue-idle-1.c @@ -12,8 +12,7 @@ static void setup(void) { q = mog_queue_new(); pipe_or_die(fds); - mfd = mog_fd_get(fds[0]); - mfd->fd = fds[0]; + mfd = mog_fd_init(fds[0], MOG_FD_TYPE_UNUSED); mog_set_nonblocking(fds[0], true); assert(read(fds[0], buf, sizeof(buf)) == -1 && -- cgit v1.2.3-24-ge0c7