]> git.pld-linux.org Git - packages/php.git/blame - php-fcgi-graceful.patch
moved C: logrotate to proper subpackage (containing logrotate file)
[packages/php.git] / php-fcgi-graceful.patch
CommitLineData
e7cc86fc
ER
1Related links:
2
c14467fd
AM
3http://bugs.php.net/bug.php?id=43224 this patch
4
e7cc86fc
ER
5http://bugs.php.net/bug.php?id=41593
6http://bugs.php.net/bug.php?id=36158
7http://php-fpm.anight.org/
8
42e16ac8
ER
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
c14467fd
AM
21--- php5.3-200711090930/sapi/cgi/cgi_main.c 2007-11-01 13:32:38.000000000 +0200
22+++ php5.3-200711090930-graceful/sapi/cgi/cgi_main.c 2007-11-09 13:34:22.974559020 +0200
23@@ -101,6 +101,9 @@
3e6c63d7
ER
24 */
25 static int parent = 1;
26
c14467fd 27+/* Socket we are listening on incoming connections */
16da4523 28+static int fcgi_fd = 0;
3e6c63d7
ER
29+
30 /**
31 * Process group
32 */
c14467fd
AM
33@@ -1221,6 +1224,21 @@
34 exit(0);
3e6c63d7
ER
35 }
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+
7a7f999c 46+ /* Close the listening socket so new processes can reuse the same port */
3e6c63d7 47+ closesocket(fcgi_fd);
16da4523 48+ fcgi_fd = 0;
3e6c63d7 49+}
c14467fd 50+
3e6c63d7
ER
51+
52 PHP_INI_BEGIN()
53 STD_PHP_INI_ENTRY("cgi.rfc2616_headers", "0", PHP_INI_ALL, OnUpdateBool, rfc2616_headers, php_cgi_globals_struct, php_cgi_globals)
54 STD_PHP_INI_ENTRY("cgi.nph", "0", PHP_INI_ALL, OnUpdateBool, nph, php_cgi_globals_struct, php_cgi_globals)
c14467fd 55@@ -1328,7 +1346,6 @@
3e6c63d7
ER
56 int requests = 0;
57 int fastcgi = fcgi_is_fastcgi();
58 char *bindpath = NULL;
59- int fcgi_fd = 0;
60 fcgi_request request;
61 int repeats = 1;
62 int benchmark = 0;
c14467fd 63@@ -1579,9 +1596,13 @@
7a7f999c
ER
64 parent = 0;
65
3e6c63d7 66 /* don't catch our signals */
7a7f999c 67- sigaction(SIGTERM, &old_term, 0);
2a5af13b
ER
68 sigaction(SIGQUIT, &old_quit, 0);
69 sigaction(SIGINT, &old_int, 0);
7a7f999c
ER
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.039119 seconds and 4 git commands to generate.