Fix bug #77934 (php-fpm kill -USR2 not working)
authorJakub Zelenka <bukka@php.net>
Sat, 11 May 2019 19:07:39 +0000 (20:07 +0100)
committerJakub Zelenka <bukka@php.net>
Sat, 11 May 2019 19:07:39 +0000 (20:07 +0100)
NEWS
sapi/fpm/fpm/fpm_signals.c
sapi/fpm/tests/bug77934-reload-process-control.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index f774605940b4cf308d451dc23ed439067476f0f8..c89f43a24bf11221fce325414d1eed542ede1af2 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ PHP                                                                        NEWS
 ?? ??? 2019, PHP 7.2.19
 
 - FPM:
+  . Fixed bug #77934 (php-fpm kill -USR2 not working). (Jakub Zelenka)
   . Fixed bug #77921 (static.php.net doesn't work anymore). (Peter Kokot)
 
 - GD:
index 0df119be3863883a919b3850b9f4d485086b5ed2..4c9f9664f65b789726671c3848785305aed9a113 100644 (file)
@@ -143,7 +143,7 @@ static void sig_soft_quit(int signo) /* {{{ */
        int saved_errno = errno;
 
        /* closing fastcgi listening socket will force fcgi_accept() exit immediately */
-       close(0);
+       close(fpm_globals.listening_socket);
        if (0 > socket(AF_UNIX, SOCK_STREAM, 0)) {
                zlog(ZLOG_WARNING, "failed to create a new socket");
        }
diff --git a/sapi/fpm/tests/bug77934-reload-process-control.phpt b/sapi/fpm/tests/bug77934-reload-process-control.phpt
new file mode 100644 (file)
index 0000000..d223403
--- /dev/null
@@ -0,0 +1,44 @@
+--TEST--
+FPM: bug77934 - php-fpm kill -USR2 not working
+--SKIPIF--
+<?php include "skipif.inc"; ?>
+--FILE--
+<?php
+
+require_once "tester.inc";
+
+$cfg = <<<EOT
+[global]
+error_log = {{FILE:LOG}}
+pid = {{FILE:PID}}
+process_control_timeout=20
+[unconfined]
+listen = {{ADDR}}
+pm = dynamic
+pm.max_children = 5
+pm.start_servers = 1
+pm.min_spare_servers = 1
+pm.max_spare_servers = 1
+EOT;
+
+$tester = new FPM\Tester($cfg);
+$tester->start();
+$tester->expectLogStartNotices();
+$tester->signal('USR2');
+$tester->expectLogNotice('Reloading in progress ...');
+$tester->expectLogNotice('reloading: .*');
+$tester->expectLogNotice('using inherited socket fd=\d+, "127.0.0.1:\d+"');
+$tester->expectLogStartNotices();
+$tester->terminate();
+$tester->expectLogTerminatingNotices();
+$tester->close();
+
+?>
+Done
+--EXPECT--
+Done
+--CLEAN--
+<?php
+require_once "tester.inc";
+FPM\Tester::clean();
+?>