shane Sun Oct 13 03:23:17 2002 EDT Modified files: /php4/sapi/cgi/libfcgi os_win32.c Log: fix shutdown issues Index: php4/sapi/cgi/libfcgi/os_win32.c diff -u php4/sapi/cgi/libfcgi/os_win32.c:1.5 php4/sapi/cgi/libfcgi/os_win32.c:1.6 --- php4/sapi/cgi/libfcgi/os_win32.c:1.5 Sun Oct 13 01:55:03 2002 +++ php4/sapi/cgi/libfcgi/os_win32.c Sun Oct 13 03:23:17 2002 @@ -17,7 +17,7 @@ * significantly more enjoyable.) */ #ifndef lint -static const char rcsid[] = "$Id: os_win32.c,v 1.5 2002/10/13 05:55:03 shane Exp $"; +static const char rcsid[] = "$Id: os_win32.c,v 1.6 2002/10/13 07:23:17 shane Exp $"; #endif /* not lint */ #define WIN32_LEAN_AND_MEAN @@ -271,24 +271,14 @@ static DWORD WINAPI ShutdownRequestThread(LPVOID arg) { HANDLE shutdownEvent = (HANDLE) arg; - - if (WaitForSingleObject(shutdownEvent, INFINITE) == WAIT_FAILED) - { - // Assuming it will happen again, all we can do is exit the thread - return 1; - } - else - { - // "Simple reads and writes to properly-aligned 32-bit variables are atomic" - shutdownPending = TRUE; - - // Before an accept() is entered the shutdownPending flag is checked. - // If set, OS_Accept() will return -1. If not, it waits - // on a connection request for one second, checks the flag, & repeats. - // Only one process/thread is allowed to do this at time by - // wrapping the accept() with mutex. - return 0; - } + WaitForSingleObject(shutdownEvent, INFINITE); + shutdownPending = TRUE; + // Before an accept() is entered the shutdownPending flag is checked. + // If set, OS_Accept() will return -1. If not, it waits + // on a connection request for one second, checks the flag, & repeats. + // Only one process/thread is allowed to do this at time by + // wrapping the accept() with mutex. + return 0; } int OS_SetImpersonate(void) @@ -1923,8 +1913,12 @@ if (acceptMutex != INVALID_HANDLE_VALUE) { - if (WaitForSingleObject(acceptMutex, INFINITE) == WAIT_FAILED) + DWORD ret; + while ((ret = WaitForSingleObject(acceptMutex, ACCEPT_TIMEOUT)) == +WAIT_TIMEOUT) { + if (shutdownPending) break; + } + if (ret == WAIT_FAILED) { printLastError("WaitForSingleObject() failed"); return -1; }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php