about summary refs log tree commit homepage
path: root/svc.c
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-06-01 03:06:56 +0000
committerEric Wong <e@80x24.org>2016-06-01 03:07:33 +0000
commita19f6bf70866e9fed34c7220f8a83d8486102821 (patch)
tree7d528c84b5489dd488a82014af755235edcd39f6 /svc.c
parentd413151f5c0e3ccd3c7c7fe9d1db9112e7e83561 (diff)
downloadcmogstored-a19f6bf70866e9fed34c7220f8a83d8486102821.tar.gz
In case "/bin/sh" or "/dev/null" becomes unavailable during the
lifetime of cmogstored, we will no longer crash when attempting
to (re)start iostat.  However, your system is probably hosed
anyways if "/bin/sh" or "/dev/null" become unavailable.

This also fixes a bug where we would leak the iostat pipe if
either fork/vfork fails.

We also close an innocuous race condition where the child
might toggle flags in the parent process and trigger an
extra wakeup.

Finally, we use sigprocmask in the child in case pthread_sigmask
does not not work on some systems after forking.  This is likely
only a cosmetic change.
Diffstat (limited to 'svc.c')
-rw-r--r--svc.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/svc.c b/svc.c
index a0c2921..43bc356 100644
--- a/svc.c
+++ b/svc.c
@@ -166,14 +166,14 @@ size_t mog_svc_each(Hash_processor processor, void *data)
         return rv;
 }
 
-static bool cloexec_disable(struct mog_fd *mfd)
+static bool cloexec_disable(struct mog_fd *mfd) /* vfork-safe */
 {
         if (mfd)
                 CHECK(int, 0, mog_set_cloexec(mfd->fd, false));
         return true;
 }
 
-static bool svc_cloexec_off_i(void *svcptr, void *unused)
+static bool svc_cloexec_off_i(void *svcptr, void *unused) /* vfork-safe */
 {
         struct mog_svc *svc = svcptr;
 
@@ -186,7 +186,7 @@ static bool svc_cloexec_off_i(void *svcptr, void *unused)
  * Only call this from a freshly forked upgrade child process.
  * This holds no locks to avoid potential deadlocks in post-fork mutexes
  */
-void mog_svc_upgrade_prepare(void)
+void mog_svc_upgrade_prepare(void) /* vfork-safe */
 {
         (void)hash_do_for_each(by_docroot, svc_cloexec_off_i, NULL);
 }