ID: 45423 Updated by: [EMAIL PROTECTED] Reported By: basant dot kukreja at sun dot com -Status: Assigned +Status: Closed Bug Type: CGI related Operating System: * PHP Version: 5.2.6 Assigned To: dmitry New Comment:
This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2008-07-15 02:03:51] [EMAIL PROTECTED] Dmitry, this patch looks okay to me..can I have a second opinion from you? :) ------------------------------------------------------------------------ [2008-07-03 02:18:45] basant dot kukreja at sun dot com Suggested fix : Php fastcgi parent process install signals and inside signal handler it calls exit. I think it is not wise to call complicated stuff like php_module_shutdown inside signal handler so in my suggested fix, I set the variable exitsignal to 1. When parent will come out of wait call, it should first invoke cleanup functions and then call exit. --- sapi/cgi/cgi_main.c_orig 2008-04-09 02:16:40.000000000 -0700 +++ sapi/cgi/cgi_main.c 2008-07-02 18:56:44.968570000 -0700 @@ -103,6 +103,12 @@ */ static int parent = 1; +/* Did parent received exit signals SIG_TERM/SIG_INT/SIG_QUIT */ +static int exitsignal = 0; + +/* Is Parent waiting for children to exit */ +static int parentwaiting = 0; + /** * Process group */ @@ -1151,9 +1157,13 @@ /* Kill all the processes in our process group */ kill(-pgroup, SIGTERM); #endif - /* We should exit at this point, but MacOSX doesn't seem to */ - exit(0); + if (parent && parentwaiting) { + exitsignal = 1; + } + else { + exit(0); + } } #endif @@ -1557,8 +1567,15 @@ #ifdef DEBUG_FASTCGI fprintf(stderr, "Wait for kids, pid %d\n", getpid()); #endif + parentwaiting = 1; while (wait(&status) < 0) { } + if (exitsignal) { + SG(server_context) = NULL; + php_module_shutdown(TSRMLS_C); + sapi_shutdown(); + exit(0); + } running--; } } ------------------------------------------------------------------------ [2008-07-03 02:16:34] basant dot kukreja at sun dot com Description: ------------ php fastcgi parent process calls sapi_startup but it doesn't call php_module_shutdown before exiting. The result of this is : 1) php behavior is different when running inside apache and inside fastcgi. When running inside apache, parent apache process calls php_module_shutdown. 2) Since php fastcgi parent doesn't call php_module_shutodown, it doesn't give modules like apc to do proper cleanup chance. Note that apc creates semaphores and it needs to know if parent process is shutting down to cleanup semaphores. Here is the APC bug link : http://pecl.php.net/bugs/bug.php?id=5280 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45423&edit=1