1 --- php5.3-200711071330/sapi/cgi/cgi_main.c 2007-11-01 13:32:38.000000000 +0200
2 +++ php5.3-200711071330-graceful2/sapi/cgi/cgi_main.c 2007-11-07 22:12:10.025949153 +0200
7 +/* Socket we are listening on incoming connections */
8 +static int fcgi_fd = 0;
13 @@ -1221,6 +1224,21 @@
18 + * Graceful shutdown. Close listening sockets.
20 +void fastcgi_graceful_shutdown(int signal)
23 + fprintf(stderr, "FastCGI graceful shutdown, pid %d\n", getpid());
26 + /* Close the listening socket so new processes can reuse the same port */
27 + closesocket(fcgi_fd);
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)
37 int fastcgi = fcgi_is_fastcgi();
38 char *bindpath = NULL;
43 @@ -1579,9 +1596,13 @@
46 /* don't catch our signals */
47 - sigaction(SIGTERM, &old_term, 0);
48 - sigaction(SIGQUIT, &old_quit, 0);
49 - sigaction(SIGINT, &old_int, 0);
50 + sigaction(SIGQUIT, &act, &old_quit);
51 + sigaction(SIGINT, &act, &old_int);
53 + /* call graceful shutdown handler for SIGTERM */
55 + act.sa_handler = fastcgi_graceful_shutdown;
56 + sigaction(SIGTERM, &act, &old_term);
59 perror("php (pre-forking)");