]> git.pld-linux.org Git - packages/php.git/blame - php-fcgi-graceful.patch
- handle graceful restart on SIGTERM, so scripts need not to be modified
[packages/php.git] / php-fcgi-graceful.patch
CommitLineData
3e6c63d7 1--- php5.3-200711071330/sapi/cgi/cgi_main.c 2007-11-01 13:32:38.000000000 +0200
7a7f999c 2+++ php5.3-200711071330-graceful2/sapi/cgi/cgi_main.c 2007-11-07 22:12:10.025949153 +0200
3e6c63d7
ER
3@@ -101,6 +101,9 @@
4 */
5 static int parent = 1;
6
7+/* Socket we are listening on incoming connections */
16da4523 8+static int fcgi_fd = 0;
3e6c63d7
ER
9+
10 /**
11 * Process group
12 */
7a7f999c 13@@ -1221,6 +1224,21 @@
3e6c63d7
ER
14 exit(0);
15 }
16
17+/**
18+ * Graceful shutdown. Close listening sockets.
19+ */
20+void fastcgi_graceful_shutdown(int signal)
21+{
22+#ifdef DEBUG_FASTCGI
23+ fprintf(stderr, "FastCGI graceful shutdown, pid %d\n", getpid());
24+#endif
25+
7a7f999c 26+ /* Close the listening socket so new processes can reuse the same port */
3e6c63d7 27+ closesocket(fcgi_fd);
16da4523 28+ fcgi_fd = 0;
3e6c63d7
ER
29+}
30+
31+
32 PHP_INI_BEGIN()
33 STD_PHP_INI_ENTRY("cgi.rfc2616_headers", "0", PHP_INI_ALL, OnUpdateBool, rfc2616_headers, php_cgi_globals_struct, php_cgi_globals)
34 STD_PHP_INI_ENTRY("cgi.nph", "0", PHP_INI_ALL, OnUpdateBool, nph, php_cgi_globals_struct, php_cgi_globals)
7a7f999c 35@@ -1328,7 +1346,6 @@
3e6c63d7
ER
36 int requests = 0;
37 int fastcgi = fcgi_is_fastcgi();
38 char *bindpath = NULL;
39- int fcgi_fd = 0;
40 fcgi_request request;
41 int repeats = 1;
42 int benchmark = 0;
7a7f999c
ER
43@@ -1579,9 +1596,13 @@
44 parent = 0;
45
3e6c63d7 46 /* don't catch our signals */
7a7f999c
ER
47- sigaction(SIGTERM, &old_term, 0);
48- sigaction(SIGQUIT, &old_quit, 0);
3e6c63d7 49- sigaction(SIGINT, &old_int, 0);
7a7f999c
ER
50+ sigaction(SIGQUIT, &act, &old_quit);
51+ sigaction(SIGINT, &act, &old_int);
52+
53+ /* call graceful shutdown handler for SIGTERM */
3e6c63d7
ER
54+ act.sa_flags = 0;
55+ act.sa_handler = fastcgi_graceful_shutdown;
7a7f999c 56+ sigaction(SIGTERM, &act, &old_term);
3e6c63d7
ER
57 break;
58 case -1:
59 perror("php (pre-forking)");
This page took 0.047876 seconds and 4 git commands to generate.