diff options
author | Anatol Belski <ab@php.net> | 2018-10-03 12:13:22 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2018-10-03 12:13:22 +0200 |
commit | dc48e01a190cbd7396deb293e5ba72858b9a2623 (patch) | |
tree | 29c9d56e25eb506d52c0c2e218b1069ed6080a3c /sapi | |
parent | 54aa76167b84b1f344d80988b7022d482c43f5ed (diff) | |
parent | b0547a3dfba6702e7cc94476d4d422374c20b4b8 (diff) | |
download | php-git-dc48e01a190cbd7396deb293e5ba72858b9a2623.tar.gz |
Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
Fixed bug #76948 Failed shutdown/reboot or end session in Windows
Diffstat (limited to 'sapi')
-rw-r--r-- | sapi/cgi/cgi_main.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 8800788117..48d622318c 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -230,9 +230,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 @@ -1496,6 +1497,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; @@ -2180,6 +2185,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 */ @@ -2228,6 +2234,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; @@ -2283,6 +2296,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; |