#40738 [NEW]: php fastcgi on windows hangs if 'reuse-connnections' is enabled

From: Date: Tue, 06 Mar 2007 08:37:01 +0000
Subject: #40738 [NEW]: php fastcgi on windows hangs if 'reuse-connnections' is enabled
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-109960@lists.php.net to get a copy of this message
From: sriram dot natarajan at sun dot com Operating system: windows PHP version: 5.2.1 PHP Bug Type: *General Issues Bug description: php fastcgi on windows hangs if 'reuse-connnections' is enabled Description: ------------ currently, when we use Php 5.2.x as 'fastcgi' plugin with web server + fastcgi support and enable 'reuse-connection' , then the php processes does not shutdown correctly. here is the issue During shutdown, the plugin sends TERM signal to the PHP primordial which in turn sends TERM to its child processes. In case of reuse-connection=1, the child PHP process which has served the request, would be waiting in "read" (within a "while" loop). If, at this time, it receives a TERM signal, then this read gets interrupted and the signal handler gets executed which sets the variable "in_shutdown" to true. Since "read" is inside the loop and there is no check for this in_shutdown variable within the loop, the PHP process continues to wait in "read". The following change in the PHP code fixed this issue. File: <php src dir>/sapi/cgi/fastcgi.c --------------------------------------------------------------- static inline ssize_t safe_read(fcgi_request *req, const void *buf, size_t count) { int ret; size_t n = 0; do { ret = read(req->fd, ((char*)buf)+n, count-n); // This check is needed to avoid looping during shutdown. + if(in_shutdown) { // missing code + return -1; } else if (ret > 0) { n += ret; } else if (ret == 0 && errno == 0) { return n; } else if (ret <= 0 && errno != 0 && errno != EINTR) { return ret; } } while (n != count); return n; } --------------------------------------------------------------- -- Edit bug report at http://bugs.php.net/?id=40738&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40738&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40738&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40738&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=40738&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=40738&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=40738&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=40738&r=needscript Try newer version: http://bugs.php.net/fix.php?id=40738&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=40738&r=support Expected behavior: http://bugs.php.net/fix.php?id=40738&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=40738&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=40738&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=40738&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40738&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=40738&r=dst IIS Stability: http://bugs.php.net/fix.php?id=40738&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=40738&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=40738&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=40738&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=40738&r=mysqlcfg

« previous php.bugs (#109960) next »