]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: mworker: block SIGCHLD until the master is ready
authorWilliam Lallemand <wlallemand@haproxy.com>
Tue, 11 Sep 2018 08:06:21 +0000 (10:06 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 11 Sep 2018 08:21:58 +0000 (10:21 +0200)
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
src/signal.c

index 1ab87b7267068cd3a9b590a3b8f082d05bad81da..69d42da74f53caf063cae7b74f36b234448fda1a 100644 (file)
@@ -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);
 }
 
index 01b6121799b86507f126df26ac2135ec50420c81..6f74a6f46fcde4f6fe0e03fe66b66b956daf61c1 100644 (file)
@@ -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);