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

From: Date: Tue, 06 Mar 2007 10:43:48 +0000
Subject: #40738 [Opn->Asn]: php fastcgi on windows hangs if 'reuse-connnections' is enabled
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-109964@lists.php.net to get a copy of this message
ID: 40738 Updated by: tony2001@php.net 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

« previous php.bugs (#109964) next »