dmitry          Fri Feb  3 16:30:09 2006 UTC

  Modified files:              (Branch: PHP_5_1)
    /php-src    NEWS 
    /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/NEWS?r1=1.2027.2.396&r2=1.2027.2.397&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.396 php-src/NEWS:1.2027.2.397
--- php-src/NEWS:1.2027.2.396   Fri Feb  3 14:46:42 2006
+++ php-src/NEWS        Fri Feb  3 16:30:09 2006
@@ -33,6 +33,8 @@
 - Fixed bug #36185 (str_rot13() crash on non-string parameter). (Pierre)
 - Fixed bug #36176 (PDO_PGSQL - PDO::exec() does not return number of rows 
   affected by the operation). (Ilia)
+- Fixed bug #36158 (SIGTERM is not handled correctly when running as a FastCGI
+  server). (Dmitry)
 - Fixed bug #36152 (problems with curl+ssl and pgsql+ssl in same PHP). (Mike)
 - Fixed bug #36148 (unpack("H*hex", $data) is adding an extra character to the 
   end of the string). (Ilia)
http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.6&r2=1.267.2.7&diff_format=u
Index: php-src/sapi/cgi/cgi_main.c
diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.6 
php-src/sapi/cgi/cgi_main.c:1.267.2.7
--- php-src/sapi/cgi/cgi_main.c:1.267.2.6       Thu Feb  2 08:17:23 2006
+++ php-src/sapi/cgi/cgi_main.c Fri Feb  3 16:30:09 2006
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: cgi_main.c,v 1.267.2.6 2006/02/02 08:17:23 dmitry Exp $ */
+/* $Id: cgi_main.c,v 1.267.2.7 2006/02/03 16:30:09 dmitry Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -274,7 +274,7 @@
 #ifndef PHP_WIN32
                !parent && 
 #endif
-               (!request || FCGX_FFlush(request->out) == -1)) {
+               request && FCGX_FFlush(request->out) == -1) {
                        php_handle_aborted_connection();
                }
                return;
@@ -1242,7 +1242,8 @@
 #ifdef DEBUG_FASTCGI
                                fprintf(stderr, "Wait for kids, pid %d\n", 
getpid());
 #endif
-                               wait(&status);
+                               while (wait(&status) < 0) {
+                               }
                                running--;
                        }
                }
@@ -1656,6 +1657,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.2.2&r2=1.4.2.3&diff_format=u
Index: php-src/sapi/cgi/fastcgi.c
diff -u php-src/sapi/cgi/fastcgi.c:1.4.2.2 php-src/sapi/cgi/fastcgi.c:1.4.2.3
--- php-src/sapi/cgi/fastcgi.c:1.4.2.2  Thu Feb  2 08:17:23 2006
+++ php-src/sapi/cgi/fastcgi.c  Fri Feb  3 16:30:09 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: fastcgi.c,v 1.4.2.2 2006/02/02 08:17:23 dmitry Exp $ */
+/* $Id: fastcgi.c,v 1.4.2.3 2006/02/03 16:30:09 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

Reply via email to