]> git.pld-linux.org Git - packages/php.git/blame - php-fcgi-graceful.patch
- 5.2.5RC2
[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
5http://php-fpm.anight.org/
6
42e16ac8
ER
7test script too:
8<?php
9echo php_sapi_name(), ' running ', PHP_VERSION, "<br>\n";
10$i = 0;
11while ($i < 35) {
12 echo (++$i), "<br>\n";
13 flush();
14 sleep(1);
15}
16echo "end!<br>\n";
17?>
18
3e6c63d7 19--- php5.3-200711071330/sapi/cgi/cgi_main.c 2007-11-01 13:32:38.000000000 +0200
7a7f999c 20+++ php5.3-200711071330-graceful2/sapi/cgi/cgi_main.c 2007-11-07 22:12:10.025949153 +0200
3e6c63d7
ER
21@@ -101,6 +101,9 @@
22 */
23 static int parent = 1;
24
25+/* Socket we are listening on incoming connections */
16da4523 26+static int fcgi_fd = 0;
3e6c63d7
ER
27+
28 /**
29 * Process group
30 */
7a7f999c 31@@ -1221,6 +1224,21 @@
3e6c63d7
ER
32 exit(0);
33 }
34
35+/**
36+ * Graceful shutdown. Close listening sockets.
37+ */
38+void fastcgi_graceful_shutdown(int signal)
39+{
40+#ifdef DEBUG_FASTCGI
41+ fprintf(stderr, "FastCGI graceful shutdown, pid %d\n", getpid());
42+#endif
43+
7a7f999c 44+ /* Close the listening socket so new processes can reuse the same port */
3e6c63d7 45+ closesocket(fcgi_fd);
16da4523 46+ fcgi_fd = 0;
3e6c63d7
ER
47+}
48+
49+
50 PHP_INI_BEGIN()
51 STD_PHP_INI_ENTRY("cgi.rfc2616_headers", "0", PHP_INI_ALL, OnUpdateBool, rfc2616_headers, php_cgi_globals_struct, php_cgi_globals)
52 STD_PHP_INI_ENTRY("cgi.nph", "0", PHP_INI_ALL, OnUpdateBool, nph, php_cgi_globals_struct, php_cgi_globals)
7a7f999c 53@@ -1328,7 +1346,6 @@
3e6c63d7
ER
54 int requests = 0;
55 int fastcgi = fcgi_is_fastcgi();
56 char *bindpath = NULL;
57- int fcgi_fd = 0;
58 fcgi_request request;
59 int repeats = 1;
60 int benchmark = 0;
7a7f999c
ER
61@@ -1579,9 +1596,13 @@
62 parent = 0;
63
3e6c63d7 64 /* don't catch our signals */
7a7f999c
ER
65- sigaction(SIGTERM, &old_term, 0);
66- sigaction(SIGQUIT, &old_quit, 0);
3e6c63d7 67- sigaction(SIGINT, &old_int, 0);
7a7f999c
ER
68+ sigaction(SIGQUIT, &act, &old_quit);
69+ sigaction(SIGINT, &act, &old_int);
70+
71+ /* call graceful shutdown handler for SIGTERM */
3e6c63d7
ER
72+ act.sa_flags = 0;
73+ act.sa_handler = fastcgi_graceful_shutdown;
7a7f999c 74+ sigaction(SIGTERM, &act, &old_term);
3e6c63d7
ER
75 break;
76 case -1:
77 perror("php (pre-forking)");
This page took 0.142246 seconds and 4 git commands to generate.