Block signals during fpm master initialization
authorMaksim Nikulin <mnikulin@plesk.com>
Wed, 24 Jul 2019 09:50:57 +0000 (16:50 +0700)
committerJakub Zelenka <bukka@php.net>
Sun, 20 Oct 2019 15:08:55 +0000 (16:08 +0100)
commitae5154c6c6af7ba7c592f8af006b7cadd0d66d6e
treea8f6703da196cd4bceb0622c4cafb9cd9492c0a1
parent62b053a3be3e77186451a503f93287a6002b62a0
Block signals during fpm master initialization

Fix PHP-FPM failure in the case of concurrent reload attempts.

Postpone signal delivery to the fpm master process till proper signal
handlers are set. Prevent the following case:

- Running master process receives `SIGUSR2` and performs `execvp()`.
- Another `SIGUSR2` is arrived before signal handlers are set.
- Master process dies.
- Requests to the HTTP server handled by PHP-fpm can not be served
  any more.

Block some signals using `sigprocmask()` before `execvp()` and early
in the `main()` function. Unblock signals as soon as proper
handlers are set.

Fixes bug #74083
sapi/fpm/fpm/fpm_main.c
sapi/fpm/fpm/fpm_process_ctl.c
sapi/fpm/fpm/fpm_signals.c
sapi/fpm/fpm/fpm_signals.h