]> git.pld-linux.org Git - packages/php.git/blame - php-fcgi-graceful.patch
use /usr/sbin/php-fpm as other branches
[packages/php.git] / php-fcgi-graceful.patch
CommitLineData
e7cc86fc
ER
1Related links:
2
3http://bugs.php.net/bug.php?id=41593
4http://bugs.php.net/bug.php?id=36158
fd3f03f7 5http://bugs.php.net/bug.php?id=43224
e7cc86fc
ER
6http://php-fpm.anight.org/
7
42e16ac8
ER
8test script too:
9<?php
10echo php_sapi_name(), ' running ', PHP_VERSION, "<br>\n";
11$i = 0;
12while ($i < 35) {
13 echo (++$i), "<br>\n";
14 flush();
15 sleep(1);
16}
17echo "end!<br>\n";
18?>
19
2a5af13b
ER
20--- php-5.2.5RC2/sapi/cgi/cgi_main.c 2007-11-01 17:23:14.000000000 +0200
21+++ php-5.2.5RC2-graceful/sapi/cgi/cgi_main.c 2007-11-08 00:46:38.999355875 +0200
22@@ -103,6 +103,11 @@
3e6c63d7
ER
23 */
24 static int parent = 1;
25
2a5af13b
ER
26+#if PHP_FASTCGI
27+/* Socket we are listening on incoming FastCGI connections */
16da4523 28+static int fcgi_fd = 0;
2a5af13b 29+#endif
3e6c63d7
ER
30+
31 /**
32 * Process group
33 */
2a5af13b 34@@ -1157,6 +1162,22 @@
3e6c63d7 35 }
2a5af13b 36 #endif
3e6c63d7 37
2a5af13b 38+#if PHP_FASTCGI
3e6c63d7
ER
39+/**
40+ * Graceful shutdown. Close listening sockets.
41+ */
42+void fastcgi_graceful_shutdown(int signal)
43+{
44+#ifdef DEBUG_FASTCGI
45+ fprintf(stderr, "FastCGI graceful shutdown, pid %d\n", getpid());
46+#endif
47+
7a7f999c 48+ /* Close the listening socket so new processes can reuse the same port */
3e6c63d7 49+ closesocket(fcgi_fd);
16da4523 50+ fcgi_fd = 0;
3e6c63d7 51+}
2a5af13b 52+#endif
3e6c63d7
ER
53+
54 PHP_INI_BEGIN()
55 STD_PHP_INI_ENTRY("cgi.rfc2616_headers", "0", PHP_INI_ALL, OnUpdateBool, rfc2616_headers, php_cgi_globals_struct, php_cgi_globals)
56 STD_PHP_INI_ENTRY("cgi.nph", "0", PHP_INI_ALL, OnUpdateBool, nph, php_cgi_globals_struct, php_cgi_globals)
2a5af13b 57@@ -1275,7 +1296,6 @@
3e6c63d7
ER
58 int requests = 0;
59 int fastcgi = fcgi_is_fastcgi();
60 char *bindpath = NULL;
61- int fcgi_fd = 0;
62 fcgi_request request;
63 int repeats = 1;
64 int benchmark = 0;
2a5af13b 65@@ -1538,9 +1558,17 @@
7a7f999c
ER
66 parent = 0;
67
3e6c63d7 68 /* don't catch our signals */
7a7f999c 69- sigaction(SIGTERM, &old_term, 0);
2a5af13b
ER
70 sigaction(SIGQUIT, &old_quit, 0);
71 sigaction(SIGINT, &old_int, 0);
72+#if PHP_FASTCGI
7a7f999c
ER
73+
74+ /* call graceful shutdown handler for SIGTERM */
3e6c63d7
ER
75+ act.sa_flags = 0;
76+ act.sa_handler = fastcgi_graceful_shutdown;
7a7f999c 77+ sigaction(SIGTERM, &act, &old_term);
2a5af13b
ER
78+#else
79+ sigaction(SIGTERM, &old_term, 0);
80+#endif
3e6c63d7
ER
81 break;
82 case -1:
83 perror("php (pre-forking)");
This page took 0.03314 seconds and 4 git commands to generate.