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.
This commit is contained in:
William Lallemand 2018-09-11 10:06:21 +02:00 committed by Willy Tarreau
parent 91c13b696a
commit ebf304f8dd
2 changed files with 4 additions and 0 deletions

View 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);
}

View 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);