forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
140 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1570,11 +1570,7 @@ int main(int argc, char *argv[]) | |
does that for us! [email protected] | ||
20000419 */ | ||
|
||
/* Subset of signals from fpm_signals_init_main() to avoid unexpected death during early init | ||
or during reload just after execvp() or fork */ | ||
int init_signal_array[] = { SIGUSR1, SIGUSR2, SIGCHLD }; | ||
if (0 > fpm_signals_init_mask(init_signal_array, sizeof(init_signal_array)/sizeof(init_signal_array[0])) || | ||
0 > fpm_signals_block()) { | ||
if (0 > fpm_signals_init_mask() || 0 > fpm_signals_block()) { | ||
zlog(ZLOG_WARNING, "Could die in the case of too early reload signal"); | ||
} | ||
zlog(ZLOG_DEBUG, "Blocked some signals"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
--TEST-- | ||
FPM: bug76601 children should not ignore signals during concurrent reloads | ||
--SKIPIF-- | ||
<?php | ||
include "skipif.inc"; | ||
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test"); | ||
?> | ||
--FILE-- | ||
<?php | ||
|
||
require_once "tester.inc"; | ||
|
||
$cfg = <<<EOT | ||
[global] | ||
error_log = {{FILE:LOG}} | ||
pid = {{FILE:PID}} | ||
; some value twice greater than tester->getLogLines() timeout | ||
process_control_timeout=10 | ||
[unconfined] | ||
listen = {{ADDR}} | ||
; spawn children immediately after reload | ||
pm = static | ||
pm.max_children = 10 | ||
EOT; | ||
|
||
$code = <<<EOT | ||
<?php | ||
/* empty */ | ||
EOT; | ||
|
||
/* | ||
* If a child miss SIGQUIT then reload process should stuck | ||
* for at least process_control_timeout that is set greater | ||
* than timout in log reading functions. | ||
* | ||
* Alternative way is to set log_level=debug and filter result of | ||
* $tester->getLogLines(2000) for lines containing SIGKILL | ||
* | ||
* [22-Oct-2019 03:28:19.532703] DEBUG: pid 21315, fpm_pctl_kill_all(), line 161: [pool unconfined] sending signal 9 SIGKILL to child 21337 | ||
* [22-Oct-2019 03:28:19.533471] DEBUG: pid 21315, fpm_children_bury(), line 259: [pool unconfined] child 21337 exited on signal 9 (SIGKILL) after 1.003055 seconds from start | ||
* | ||
* but it has less probability of failure detection. Additionally it requires more | ||
* $tester->expectLogNotice() around last reload due to presence of debug messages. | ||
*/ | ||
|
||
$tester = new FPM\Tester($cfg, $code); | ||
$tester->start(); | ||
$tester->expectLogStartNotices(); | ||
|
||
/* Vary interval between concurrent reload requests | ||
since performance of test instance is not known in advance */ | ||
$max_interval = 25000; | ||
$step = 1000; | ||
$pid = $tester->getPid(); | ||
for ($interval = 0; $interval < $max_interval; $interval += $step) { | ||
exec("kill -USR2 $pid", $out, $killExitCode); | ||
if ($killExitCode) { | ||
echo "ERROR: master process is dead\n"; | ||
break; | ||
} | ||
usleep($interval); | ||
} | ||
echo "Reached interval $interval us with $step us steps\n"; | ||
$tester->expectLogNotice('Reloading in progress ...'); | ||
/* Consume mix of 'Reloading in progress ...' and 'reloading: .*' */ | ||
$skipped = $tester->getLogLines(2000); | ||
|
||
$tester->signal('USR2'); | ||
$tester->expectLogNotice('Reloading in progress ...'); | ||
/* When a child ignores SIGQUIT, the following expectation fails due to timeout. */ | ||
if (!$tester->expectLogNotice('reloading: .*')) { | ||
/* for troubleshooting */ | ||
echo "Skipped messages\n"; | ||
echo implode('', $skipped); | ||
} | ||
$tester->expectLogNotice('using inherited socket fd=\d+, "127.0.0.1:\d+"'); | ||
$tester->expectLogStartNotices(); | ||
|
||
$tester->terminate(); | ||
$tester->expectLogTerminatingNotices(); | ||
$tester->close(); | ||
|
||
?> | ||
Done | ||
--EXPECT-- | ||
Reached interval 25000 us with 1000 us steps | ||
Done | ||
--CLEAN-- | ||
<?php | ||
require_once "tester.inc"; | ||
FPM\Tester::clean(); | ||
?> |