diff options
author | Eric Wong <normalperson@yhbt.net> | 2012-02-23 03:32:46 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2012-02-23 03:32:46 +0000 |
commit | 9a8e11a3d12db94ab7b5e6990326cf344d775bdf (patch) | |
tree | 13dd0271131873909b1c88a6d354d33bf42323d1 /notify.c | |
parent | 8d0eae7fd0eb8081c7be21afe31a65157dedb118 (diff) | |
download | cmogstored-9a8e11a3d12db94ab7b5e6990326cf344d775bdf.tar.gz |
There's no point in having this run in the busier worker threads which have less stack.
Diffstat (limited to 'notify.c')
-rw-r--r-- | notify.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -8,13 +8,13 @@ static struct mog_fd *notifywr_mfd; static struct mog_notifywr *notifywr; static time_t usage_file_updated_at; static time_t usage_file_interval = 10; +struct mog_queue *mog_notify_queue; void mog_notify_init(void) { const char *interval = getenv("MOG_DISK_USAGE_INTERVAL"); struct mog_fd *mfd; int self_pipe[2]; - struct mog_queue *queue; if (pipe2(self_pipe, O_NONBLOCK | O_CLOEXEC) < 0) die("failed to init self-pipe: %s\n", strerror(errno)); @@ -26,14 +26,15 @@ void mog_notify_init(void) usage_file_interval = (time_t)i; } - queue = mog_queue_new(); + assert(mog_notify_queue == NULL && "notify queue already initialized"); + mog_notify_queue = mog_queue_new(); mfd = mog_fd_get(self_pipe[0]); mfd->fd = self_pipe[0]; mfd->queue_state = MOG_QUEUE_STATE_NEW; assert((mfd->in_queue = 0) == 0 && "in_queue check"); mfd->fd_type = MOG_FD_TYPE_NOTIFYRD; - mfd->as.notifyrd.queue = queue; - mog_idleq_push(queue, mfd, MOG_QEV_RD); + mfd->as.notifyrd.queue = mog_notify_queue; + mog_idleq_push(mog_notify_queue, mfd, MOG_QEV_RD); notifywr_mfd = mfd = mog_fd_get(self_pipe[1]); mfd->fd = self_pipe[1]; @@ -41,7 +42,7 @@ void mog_notify_init(void) mfd->fd_type = MOG_FD_TYPE_NOTIFYWR; assert((mfd->in_queue = 0) == 0 && "in_queue check"); notifywr = &mfd->as.notifywr; - notifywr->queue = queue; + notifywr->queue = mog_notify_queue; memset(notifywr->notes, 0, sizeof(notifywr->notes)); } @@ -76,6 +77,7 @@ static void notify_queue_step(struct mog_fd *mfd) { switch (mfd->fd_type) { case MOG_FD_TYPE_NOTIFYRD: notifyrd_queue_step(mfd); return; + case MOG_FD_TYPE_IOSTAT: mog_iostat_queue_step(mfd); return; default: assert(0 && mfd->fd_type && "bad fd_type in queue"); } |