com php-src: Fixed bug #76948 Failed shutdown/reboot or end session in Windows: sapi/cgi/cgi_main.c

From: Date: Wed, 03 Oct 2018 10:11:43 +0000
Subject: com php-src: Fixed bug #76948 Failed shutdown/reboot or end session in Windows: sapi/cgi/cgi_main.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-103326@lists.php.net to get a copy of this message
Commit: b0547a3dfba6702e7cc94476d4d422374c20b4b8 Author: Anatol Belski <ab@php.net> Wed, 3 Oct 2018 12:11:43 +0200 Parents: 945f315506538208705d370f39a6896371e48ebb Branches: PHP-7.1 PHP-7.2 PHP-7.3 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b0547a3dfba6702e7cc94476d4d422374c20b4b8 Log: Fixed bug #76948 Failed shutdown/reboot or end session in Windows Bugs: https://bugs.php.net/76948 Changed paths: M sapi/cgi/cgi_main.c Diff: diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index b0f1c1b..d571cf0 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -226,9 +226,10 @@ static php_cgi_globals_struct php_cgi_globals; #ifdef PHP_WIN32 #define WIN32_MAX_SPAWN_CHILDREN 64 HANDLE kid_cgi_ps[WIN32_MAX_SPAWN_CHILDREN]; -int kids; +int kids, cleaning_up = 0; HANDLE job = NULL; JOBOBJECT_EXTENDED_LIMIT_INFORMATION job_info = { 0 }; +CRITICAL_SECTION cleanup_lock; #endif #ifndef HAVE_ATTRIBUTE_WEAK @@ -1492,6 +1493,10 @@ BOOL WINAPI fastcgi_cleanup(DWORD sig) { int i = kids; + EnterCriticalSection(&cleanup_lock); + cleaning_up = 1; + LeaveCriticalSection(&cleanup_lock); + while (0 < i--) { if (NULL == kid_cgi_ps[i]) { continue; @@ -2186,6 +2191,7 @@ consult the installation file that came with this distribution, or visit \n\ ZeroMemory(&kid_cgi_ps, sizeof(kid_cgi_ps)); kids = children < WIN32_MAX_SPAWN_CHILDREN ? children : WIN32_MAX_SPAWN_CHILDREN; + InitializeCriticalSection(&cleanup_lock); SetConsoleCtrlHandler(fastcgi_cleanup, TRUE); /* kids will inherit the env, don't let them spawn */ @@ -2234,6 +2240,13 @@ consult the installation file that came with this distribution, or visit \n\ } while (parent) { + EnterCriticalSection(&cleanup_lock); + if (cleaning_up) { + DeleteCriticalSection(&cleanup_lock); + goto parent_out; + } + LeaveCriticalSection(&cleanup_lock); + i = kids; while (0 < i--) { DWORD status; @@ -2289,6 +2302,8 @@ consult the installation file that came with this distribution, or visit \n\ /* restore my env */ SetEnvironmentVariable("PHP_FCGI_CHILDREN", kid_buf); + DeleteCriticalSection(&cleanup_lock); + goto parent_out; } else { parent = 0;

« previous php.cvs (#103326) next »