1--TEST-- 2Concurrent reload signals should not kill PHP-FPM master process. (Bug: #74083) 3--SKIPIF-- 4<?php 5include "skipif.inc"; 6if (getenv("SKIP_SLOW_TESTS")) die("skip slow test"); 7?> 8--FILE-- 9<?php 10 11require_once "tester.inc"; 12 13$cfg = <<<EOT 14[global] 15error_log = {{FILE:LOG}} 16pid = {{FILE:PID}} 17process_control_timeout=1 18[unconfined] 19listen = {{ADDR}} 20ping.path = /ping 21ping.response = pong 22pm = dynamic 23pm.max_children = 5 24pm.start_servers = 1 25pm.min_spare_servers = 1 26pm.max_spare_servers = 1 27EOT; 28 29$code = <<<EOT 30<?php 31/* empty */ 32EOT; 33 34$tester = new FPM\Tester($cfg, $code); 35$tester->start(); 36$tester->expectLogStartNotices(); 37$tester->ping('{{ADDR}}'); 38 39/* Vary interval between concurrent reload requests 40 since performance of test instance is not known in advance */ 41$max_interval = 25000; 42$step = 1000; 43$pid = $tester->getPid(); 44for ($interval = 0; $interval < $max_interval; $interval += $step) { 45 exec("kill -USR2 $pid", $out, $killExitCode); 46 if ($killExitCode) { 47 echo "ERROR: master process is dead\n"; 48 break; 49 } 50 usleep($interval); 51} 52echo "Reached interval $interval us with $step us steps\n"; 53$tester->expectLogNotice('Reloading in progress ...'); 54/* Consume mix of 'Reloading in progress ...' and 'reloading: .*' */ 55$tester->getLogLines(2000); 56 57$tester->signal('USR2'); 58$tester->expectLogNotice('Reloading in progress ...'); 59$tester->expectLogNotice('reloading: .*'); 60$tester->expectLogNotice('using inherited socket fd=\d+, "127.0.0.1:\d+"'); 61$tester->expectLogStartNotices(); 62$tester->ping('{{ADDR}}'); 63 64$tester->terminate(); 65$tester->expectLogTerminatingNotices(); 66$tester->close(); 67 68?> 69Done 70--EXPECT-- 71Reached interval 25000 us with 1000 us steps 72Done 73--CLEAN-- 74<?php 75require_once "tester.inc"; 76FPM\Tester::clean(); 77?> 78