|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-03-06 13:14 UTC] dmitry@php.net
[2007-03-14 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 23 07:00:01 2025 UTC |
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; } ---------------------------------------------------------------