about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-12-02 04:28:54 +0000
committerEric Wong <normalperson@yhbt.net>2013-12-02 04:34:23 +0000
commit1a4a94f338dbe641a3f1b27a080fc34bac7f43d4 (patch)
treeff3693dccaaba9030c6cd3768328bca8144be78a
parentb7bda87ead4a53bb792dbbfb6079aad8cd4170de (diff)
downloadcmogstored-1a4a94f338dbe641a3f1b27a080fc34bac7f43d4.tar.gz
This only affects users of the undocumented --worker-processes
switch.  Furthermore, this only affects non-Linux platforms which
rely on the pipe implementation of selfwake.

This prevents us from wasting one extraneous file descriptor slot
(and hence potentially wasting 128 bytes in userland).
-rw-r--r--cmogstored.c2
-rw-r--r--selfwake.h2
2 files changed, 4 insertions, 0 deletions
diff --git a/cmogstored.c b/cmogstored.c
index 31bdd85..6aaeb92 100644
--- a/cmogstored.c
+++ b/cmogstored.c
@@ -418,6 +418,7 @@ static void fork_worker(unsigned worker_id)
         if (pid > 0) {
                 mog_process_register(pid, worker_id);
         } else if (pid == 0) {
+                mog_selfwake_put(master_selfwake);
                 mog_process_reset();
                 mog_svc_each(mog_svc_atfork_child, &parent);
 
@@ -501,6 +502,7 @@ static void run_master(void)
                 if (do_exit)
                         running = mog_kill_each_worker(SIGQUIT);
         }
+        mog_selfwake_put(master_selfwake);
 }
 
 int main(int argc, char *argv[], char *envp[])
diff --git a/selfwake.h b/selfwake.h
index 37bf0f6..15c0ac0 100644
--- a/selfwake.h
+++ b/selfwake.h
@@ -23,6 +23,7 @@ struct mog_selfpipe {
 struct mog_fd * mog_selfwake_new(void);
 void mog_selfwake_trigger(struct mog_fd *);
 void mog_selfwake_drain(struct mog_fd *);
+#define mog_selfwake_put(mfd) mog_fd_put((mfd))
 static inline void mog_selfwake_interrupt(void) {}
 void mog_selfwake_wait(struct mog_fd *);
 #else /* use Linux-only facilities like epoll_pwait or ppoll */
@@ -33,6 +34,7 @@ static inline void mog_selfwake_wait(struct mog_fd *mfd)
 static inline struct mog_fd * mog_selfwake_new(void) { return NULL; }
 static inline void mog_selfwake_trigger(struct mog_fd *mfd) {}
 static inline void mog_selfwake_drain(struct mog_fd *mfd) {}
+static inline void mog_selfwake_put(struct mog_fd *mfd) {}
 static inline void mog_selfwake_interrupt(void)
 {
         CHECK(int, 0, kill(getpid(), SIGURG));