]> git.pld-linux.org Git - packages/php.git/blame - php-fcgi-graceful.patch
- up to 8.0.7; soname to reflect that this is php 8
[packages/php.git] / php-fcgi-graceful.patch
CommitLineData
c0240cb1 1Related links:
2
3http://bugs.php.net/bug.php?id=43224 this patch
4
5http://bugs.php.net/bug.php?id=41593
6http://bugs.php.net/bug.php?id=36158
7http://php-fpm.anight.org/
8
9test script too:
10<?php
11echo php_sapi_name(), ' running ', PHP_VERSION, "<br>\n";
12$i = 0;
13while ($i < 35) {
14 echo (++$i), "<br>\n";
15 flush();
16 sleep(1);
17}
18echo "end!<br>\n";
19?>
20
7c9f5c54
ER
21--- php-7.1.0alpha2/sapi/cgi/cgi_main.c~ 2016-07-04 14:56:49.000000000 +0300
22+++ php-7.1.0alpha2/sapi/cgi/cgi_main.c 2016-07-04 14:58:17.522958766 +0300
c0240cb1 23@@ -101,6 +101,9 @@
24 */
25 static int parent = 1;
26
27+/* Socket we are listening on incoming connections */
28+static int fcgi_fd = 0;
29+
a17aa399
AG
30 #ifndef PHP_WIN32
31 /* Did parent received exit signals SIG_TERM/SIG_INT/SIG_QUIT */
32 static int exit_signal = 0;
c0240cb1 33@@ -1221,6 +1224,21 @@
c0240cb1 34 }
a17aa399 35 #endif
c0240cb1 36
37+/**
38+ * Graceful shutdown. Close listening sockets.
39+ */
40+void fastcgi_graceful_shutdown(int signal)
41+{
42+#ifdef DEBUG_FASTCGI
43+ fprintf(stderr, "FastCGI graceful shutdown, pid %d\n", getpid());
44+#endif
45+
46+ /* Close the listening socket so new processes can reuse the same port */
47+ closesocket(fcgi_fd);
48+ fcgi_fd = 0;
49+}
50+
51+
52 PHP_INI_BEGIN()
a17aa399
AG
53 STD_PHP_INI_BOOLEAN("cgi.rfc2616_headers", "0", PHP_INI_ALL, OnUpdateBool, rfc2616_headers, php_cgi_globals_struct, php_cgi_globals)
54 STD_PHP_INI_BOOLEAN("cgi.nph", "0", PHP_INI_ALL, OnUpdateBool, nph, php_cgi_globals_struct, php_cgi_globals)
02d2dcbb 55@@ -1764,7 +1764,6 @@
c0240cb1 56 int requests = 0;
02d2dcbb 57 int fastcgi;
c0240cb1 58 char *bindpath = NULL;
59- int fcgi_fd = 0;
02d2dcbb 60 fcgi_request *request = NULL;
a17aa399 61 int warmup_repeats = 0;
c0240cb1 62 int repeats = 1;
7c9f5c54 63@@ -2080,9 +2080,14 @@
00938eac 64 parent = 0;
c0240cb1 65
7c9f5c54 66 /* don't catch our signals */
00938eac
ER
67- sigaction(SIGTERM, &old_term, 0);
68 sigaction(SIGQUIT, &old_quit, 0);
69 sigaction(SIGINT, &old_int, 0);
c0240cb1 70+
00938eac
ER
71+ /* call graceful shutdown handler for SIGTERM */
72+ act.sa_flags = 0;
73+ act.sa_handler = fastcgi_graceful_shutdown;
74+ sigaction(SIGTERM, &act, &old_term);
7c9f5c54
ER
75+
76 zend_signal_init();
00938eac
ER
77 break;
78 case -1:
This page took 0.146915 seconds and 4 git commands to generate.