dmitry Fri Feb 3 16:30:27 2006 UTC Modified files: /php-src/sapi/cgi cgi_main.c fastcgi.c Log: Fixed bug #36158 (SIGTERM is not handled correctly when running as a FastCGI server) http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.274&r2=1.275&diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.274 php-src/sapi/cgi/cgi_main.c:1.275 --- php-src/sapi/cgi/cgi_main.c:1.274 Sun Jan 1 13:09:57 2006 +++ php-src/sapi/cgi/cgi_main.c Fri Feb 3 16:30:27 2006 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: cgi_main.c,v 1.274 2006/01/01 13:09:57 sniper Exp $ */ +/* $Id: cgi_main.c,v 1.275 2006/02/03 16:30:27 dmitry Exp $ */ #include "php.h" #include "php_globals.h" @@ -269,7 +269,7 @@ #ifndef PHP_WIN32 !parent && #endif - (!request || FCGX_FFlush(request->out) == -1)) { + request && FCGX_FFlush(request->out) == -1) { php_handle_aborted_connection(); } return; @@ -1200,7 +1200,8 @@ #ifdef DEBUG_FASTCGI fprintf(stderr, "Wait for kids, pid %d\n", getpid()); #endif - wait(&status); + while (wait(&status) < 0) { + } running--; } } @@ -1589,6 +1590,7 @@ exit_status = 255; } zend_end_try(); + SG(server_context) = NULL; php_module_shutdown(TSRMLS_C); sapi_shutdown(); http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.4&r2=1.5&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.4 php-src/sapi/cgi/fastcgi.c:1.5 --- php-src/sapi/cgi/fastcgi.c:1.4 Sun Jan 1 13:09:57 2006 +++ php-src/sapi/cgi/fastcgi.c Fri Feb 3 16:30:27 2006 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: fastcgi.c,v 1.4 2006/01/01 13:09:57 sniper Exp $ */ +/* $Id: fastcgi.c,v 1.5 2006/02/03 16:30:27 dmitry Exp $ */ #include "fastcgi.h" #include "php.h" @@ -157,7 +157,7 @@ static void fcgi_signal_handler(int signo) { - if (signo == SIGUSR1) { + if (signo == SIGUSR1 || signo == SIGTERM) { in_shutdown = 1; } } @@ -217,6 +217,7 @@ new_sa.sa_flags = 0; new_sa.sa_handler = fcgi_signal_handler; sigaction(SIGUSR1, &new_sa, NULL); + sigaction(SIGTERM, &new_sa, NULL); sigaction(SIGPIPE, NULL, &old_sa); if (old_sa.sa_handler == SIG_DFL) { sigaction(SIGPIPE, &new_sa, NULL); @@ -627,6 +628,9 @@ while (1) { if (req->fd < 0) { while (1) { + if (in_shutdown) { + return -1; + } #ifdef _WIN32 HANDLE pipe = (HANDLE)_get_osfhandle(req->listen_socket); OVERLAPPED ov; @@ -663,7 +667,7 @@ FCGI_UNLOCK(req->listen_socket); #endif - if (in_shutdown || (req->fd < 0 && errno != EINTR)) { + if (req->fd < 0 && (in_shutdown || errno != EINTR)) { return -1; } @@ -686,6 +690,8 @@ } #endif } + } else if (in_shutdown) { + return -1; } if (fcgi_read_request(req)) { return req->fd;
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php