diff options
author | Eric Wong <e@80x24.org> | 2016-06-01 03:06:56 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-06-01 03:07:33 +0000 |
commit | a19f6bf70866e9fed34c7220f8a83d8486102821 (patch) | |
tree | 7d528c84b5489dd488a82014af755235edcd39f6 /svc.c | |
parent | d413151f5c0e3ccd3c7c7fe9d1db9112e7e83561 (diff) | |
download | cmogstored-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.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -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); } |