ID: 40738
Updated by: [EMAIL PROTECTED]
Reported By: sriram dot natarajan at sun dot com
-Status: Open
+Status: Assigned
-Bug Type: *General Issues
+Bug Type: CGI related
Operating System: windows
PHP Version: 5.2.1
-Assigned To:
+Assigned To: dmitry
Previous Comments:
------------------------------------------------------------------------
[2007-03-06 08:37:00] sriram dot natarajan at sun dot com
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 this bug report at http://bugs.php.net/?id=40738&edit=1