]> git.pld-linux.org Git - packages/php.git/blame - php-fcgi-graceful.patch
icu rebuild
[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
791b59e4
JR
21diff -urNp -x '*.orig' php-5.6.40.org/sapi/cgi/cgi_main.c php-5.6.40/sapi/cgi/cgi_main.c
22--- php-5.6.40.org/sapi/cgi/cgi_main.c 2019-01-09 10:54:13.000000000 +0100
23+++ php-5.6.40/sapi/cgi/cgi_main.c 2021-08-23 23:19:27.222458494 +0200
24@@ -111,6 +111,9 @@ static void (*php_php_import_environment
25 static int children = 0;
26
c0240cb1 27
28+/* Socket we are listening on incoming connections */
29+static int fcgi_fd = 0;
30+
31 /**
791b59e4 32 * Set to non-zero if we are the parent process
c0240cb1 33 */
791b59e4 34@@ -1461,6 +1464,21 @@ void fastcgi_cleanup(int signal)
c0240cb1 35 }
791b59e4 36 #endif
c0240cb1 37
38+/**
39+ * Graceful shutdown. Close listening sockets.
40+ */
41+void fastcgi_graceful_shutdown(int signal)
42+{
43+#ifdef DEBUG_FASTCGI
44+ fprintf(stderr, "FastCGI graceful shutdown, pid %d\n", getpid());
45+#endif
46+
47+ /* Close the listening socket so new processes can reuse the same port */
48+ closesocket(fcgi_fd);
49+ fcgi_fd = 0;
50+}
51+
52+
53 PHP_INI_BEGIN()
54 STD_PHP_INI_ENTRY("cgi.rfc2616_headers", "0", PHP_INI_ALL, OnUpdateBool, rfc2616_headers, php_cgi_globals_struct, php_cgi_globals)
55 STD_PHP_INI_ENTRY("cgi.nph", "0", PHP_INI_ALL, OnUpdateBool, nph, php_cgi_globals_struct, php_cgi_globals)
791b59e4 56@@ -1759,7 +1777,6 @@ int main(int argc, char *argv[])
c0240cb1 57 int requests = 0;
02d2dcbb 58 int fastcgi;
c0240cb1 59 char *bindpath = NULL;
60- int fcgi_fd = 0;
02d2dcbb 61 fcgi_request *request = NULL;
c0240cb1 62 int repeats = 1;
63 int benchmark = 0;
791b59e4 64@@ -2058,9 +2075,13 @@ consult the installation file that came
c0240cb1 65 parent = 0;
66
67 /* don't catch our signals */
68- sigaction(SIGTERM, &old_term, 0);
69 sigaction(SIGQUIT, &old_quit, 0);
70 sigaction(SIGINT, &old_int, 0);
71+
72+ /* call graceful shutdown handler for SIGTERM */
73+ act.sa_flags = 0;
74+ act.sa_handler = fastcgi_graceful_shutdown;
75+ sigaction(SIGTERM, &act, &old_term);
76 break;
77 case -1:
78 perror("php (pre-forking)");
This page took 0.177205 seconds and 4 git commands to generate.