From ebf304f8dd02497ceaf6f50b50afc59c26a77ee1 Mon Sep 17 00:00:00 2001 From: William Lallemand Date: Tue, 11 Sep 2018 10:06:21 +0200 Subject: [PATCH] MEDIUM: mworker: block SIGCHLD until the master is ready With the new way of handling the signals in the master worker, we are are not staying in a waitpid() loop. Which means that we need to catch the SIGCHLD signals to call waitpid(). The problem is when the master is reloading, this signal is neither registered nor blocked so we lost all signals between the restart and the call to mworker_loop(). This patch blocks the SIGCHLD signals before the reloading and ensure it's not unblocked before the master registered the SIGCHLD handler. --- src/haproxy.c | 2 ++ src/signal.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/haproxy.c b/src/haproxy.c index 1ab87b726..69d42da74 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -493,6 +493,7 @@ static void mworker_block_signals() sigaddset(&set, SIGHUP); sigaddset(&set, SIGINT); sigaddset(&set, SIGTERM); + sigaddset(&set, SIGCHLD); ha_sigmask(SIG_SETMASK, &set, NULL); } @@ -506,6 +507,7 @@ static void mworker_unblock_signals() sigaddset(&set, SIGHUP); sigaddset(&set, SIGINT); sigaddset(&set, SIGTERM); + sigaddset(&set, SIGCHLD); ha_sigmask(SIG_UNBLOCK, &set, NULL); } diff --git a/src/signal.c b/src/signal.c index 01b612179..6f74a6f46 100644 --- a/src/signal.c +++ b/src/signal.c @@ -118,6 +118,8 @@ int signal_init() * parsing We don't want the process to be killed by an unregistered * USR2 signal when the master-worker is reloading */ sigaddset(&blocked_sig, SIGUSR2); + sigaddset(&blocked_sig, SIGCHLD); + ha_sigmask(SIG_SETMASK, &blocked_sig, NULL); sigfillset(&blocked_sig);