Re: [PHP-CVS] cvs: php-src(PHP_5_3) / NEWS /sapi/cgi cgi_main.c fastcgi.c fastcgi.h
Isn't this a bug fix? Where's the MFH to PHP_5_2 ? --Jani Arnaud Le Blanc wrote: lbarnaudTue Oct 21 03:19:28 2008 UTC Modified files: (Branch: PHP_5_3) /php-src NEWS /php-src/sapi/cgi cgi_main.c fastcgi.c fastcgi.h Log: MFH: Fixed FCGI_GET_VALUES requests (fixes #45522) http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.345&r2=1.2027.2.547.2.965.2.346&diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.547.2.965.2.345 php-src/NEWS:1.2027.2.547.2.965.2.346 --- php-src/NEWS:1.2027.2.547.2.965.2.345 Wed Oct 15 18:41:57 2008 +++ php-src/NEWSTue Oct 21 03:19:28 2008 @@ -48,6 +48,8 @@ (Christian Schneider, Arnaud) - Fixed bug #45911 (Cannot disable ext/hash). (Arnaud) - Fixed bug #45907 (undefined reference to 'PHP_SHA512Init'). (Greg) +- Fixed buf #45522 (FCGI_GET_VALUES request does not return supplied values). + (Arnaud) - Fixed bug #45392 (ob_start()/ob_end_clean() and memory_limit). (Ilia) - Fixed bug #45382 (timeout bug in stream_socket_enable_crypto). (vnegrier at optilian dot com, Ilia) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.29&r2=1.267.2.15.2.50.2.30&diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.29 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.30 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.29Fri Oct 17 01:31:12 2008 +++ php-src/sapi/cgi/cgi_main.c Tue Oct 21 03:19:28 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.29 2008/10/17 01:31:12 iliaa Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.30 2008/10/21 03:19:28 lbarnaud Exp $ */ #include "php.h" #include "php_globals.h" @@ -1608,11 +1608,18 @@ #ifndef PHP_WIN32 /* Pre-fork, if required */ if (getenv("PHP_FCGI_CHILDREN")) { - children = atoi(getenv("PHP_FCGI_CHILDREN")); + char * children_str = getenv("PHP_FCGI_CHILDREN"); + children = atoi(children_str); if (children < 0) { fprintf(stderr, "PHP_FCGI_CHILDREN is not valid\n"); return FAILURE; } + fcgi_set_mgmt_var("FCGI_MAX_CONNS", sizeof("FCGI_MAX_CONNS")-1, children_str, strlen(children_str)); + /* This is the number of concurrent requests, equals FCGI_MAX_CONNS */ + fcgi_set_mgmt_var("FCGI_MAX_REQS", sizeof("FCGI_MAX_REQS")-1, children_str, strlen(children_str)); + } else { + fcgi_set_mgmt_var("FCGI_MAX_CONNS", sizeof("FCGI_MAX_CONNS")-1, "1", sizeof("1")-1); + fcgi_set_mgmt_var("FCGI_MAX_REQS", sizeof("FCGI_MAX_REQS")-1, "1", sizeof("1")-1); } if (children) { http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.4.2.13.2.28.2.6&r2=1.4.2.13.2.28.2.7&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.6 php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.7 --- php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.6Tue Aug 26 09:56:08 2008 +++ php-src/sapi/cgi/fastcgi.c Tue Oct 21 03:19:28 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.4.2.13.2.28.2.6 2008/08/26 09:56:08 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.4.2.13.2.28.2.7 2008/10/21 03:19:28 lbarnaud Exp $ */ #include "php.h" #include "fastcgi.h" @@ -133,18 +133,7 @@ struct sockaddr_in sa_inet; } sa_t; -typedef struct _fcgi_mgmt_rec { - char* name; - char name_len; - char val; -} fcgi_mgmt_rec; - -static const fcgi_mgmt_rec fcgi_mgmt_vars[] = { - {"FCGI_MAX_CONNS", sizeof("FCGI_MAX_CONNS")-1, 1}, - {"FCGI_MAX_REQS", sizeof("FCGI_MAX_REQS")-1, 1}, - {"FCGI_MPXS_CONNS", sizeof("FCGI_MPXS_CONNS")-1, 0} -}; - +static HashTable fcgi_mgmt_vars; static int is_initialized = 0; static int is_fastcgi = 0; @@ -194,6 +183,8 @@ int fcgi_init(void) { if (!is_initialized) { + zend_hash_init(&fcgi_mgmt_vars, 0, NULL, fcgi_free_mgmt_var_cb, 1); + fcgi_set_mgmt_var("FCGI_MPXS_CONNS", sizeof("FCGI_MPXS_CONNS")-1, "0", sizeof("0")-1); #ifdef _WIN32 # if 0 /* TODO: Support for TCP sockets */ @@ -260,6 +251,9 @@ void fcgi_shutdown(void) { + if (is_initialized) { + zend_hash_destroy(&fcgi_mgmt_vars); + } is_fastcgi = 0; } @@ -750,8 +744,13 @@ padding = hdr.paddingLength; } } else if (hdr.type == FCGI_GET_VALUES) { - int j; unsigned char *p = buf + sizeof(fcgi_header); + HashPosition pos; + char * str_index; + uint str_length; + ulong num_index; + int key_type; + zval
[PHP-CVS] cvs: php-src(PHP_5_3) / NEWS /sapi/cgi cgi_main.c fastcgi.c fastcgi.h
lbarnaudTue Oct 21 03:19:28 2008 UTC Modified files: (Branch: PHP_5_3) /php-srcNEWS /php-src/sapi/cgi cgi_main.c fastcgi.c fastcgi.h Log: MFH: Fixed FCGI_GET_VALUES requests (fixes #45522) http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.345&r2=1.2027.2.547.2.965.2.346&diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.547.2.965.2.345 php-src/NEWS:1.2027.2.547.2.965.2.346 --- php-src/NEWS:1.2027.2.547.2.965.2.345 Wed Oct 15 18:41:57 2008 +++ php-src/NEWSTue Oct 21 03:19:28 2008 @@ -48,6 +48,8 @@ (Christian Schneider, Arnaud) - Fixed bug #45911 (Cannot disable ext/hash). (Arnaud) - Fixed bug #45907 (undefined reference to 'PHP_SHA512Init'). (Greg) +- Fixed buf #45522 (FCGI_GET_VALUES request does not return supplied values). + (Arnaud) - Fixed bug #45392 (ob_start()/ob_end_clean() and memory_limit). (Ilia) - Fixed bug #45382 (timeout bug in stream_socket_enable_crypto). (vnegrier at optilian dot com, Ilia) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.29&r2=1.267.2.15.2.50.2.30&diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.29 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.30 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.29Fri Oct 17 01:31:12 2008 +++ php-src/sapi/cgi/cgi_main.c Tue Oct 21 03:19:28 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.29 2008/10/17 01:31:12 iliaa Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.30 2008/10/21 03:19:28 lbarnaud Exp $ */ #include "php.h" #include "php_globals.h" @@ -1608,11 +1608,18 @@ #ifndef PHP_WIN32 /* Pre-fork, if required */ if (getenv("PHP_FCGI_CHILDREN")) { - children = atoi(getenv("PHP_FCGI_CHILDREN")); + char * children_str = getenv("PHP_FCGI_CHILDREN"); + children = atoi(children_str); if (children < 0) { fprintf(stderr, "PHP_FCGI_CHILDREN is not valid\n"); return FAILURE; } + fcgi_set_mgmt_var("FCGI_MAX_CONNS", sizeof("FCGI_MAX_CONNS")-1, children_str, strlen(children_str)); + /* This is the number of concurrent requests, equals FCGI_MAX_CONNS */ + fcgi_set_mgmt_var("FCGI_MAX_REQS", sizeof("FCGI_MAX_REQS")-1, children_str, strlen(children_str)); + } else { + fcgi_set_mgmt_var("FCGI_MAX_CONNS", sizeof("FCGI_MAX_CONNS")-1, "1", sizeof("1")-1); + fcgi_set_mgmt_var("FCGI_MAX_REQS", sizeof("FCGI_MAX_REQS")-1, "1", sizeof("1")-1); } if (children) { http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.4.2.13.2.28.2.6&r2=1.4.2.13.2.28.2.7&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.6 php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.7 --- php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.6Tue Aug 26 09:56:08 2008 +++ php-src/sapi/cgi/fastcgi.c Tue Oct 21 03:19:28 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.4.2.13.2.28.2.6 2008/08/26 09:56:08 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.4.2.13.2.28.2.7 2008/10/21 03:19:28 lbarnaud Exp $ */ #include "php.h" #include "fastcgi.h" @@ -133,18 +133,7 @@ struct sockaddr_in sa_inet; } sa_t; -typedef struct _fcgi_mgmt_rec { - char* name; - char name_len; - char val; -} fcgi_mgmt_rec; - -static const fcgi_mgmt_rec fcgi_mgmt_vars[] = { - {"FCGI_MAX_CONNS", sizeof("FCGI_MAX_CONNS")-1, 1}, - {"FCGI_MAX_REQS", sizeof("FCGI_MAX_REQS")-1, 1}, - {"FCGI_MPXS_CONNS", sizeof("FCGI_MPXS_CONNS")-1, 0} -}; - +static HashTable fcgi_mgmt_vars; static int is_initialized = 0; static int is_fastcgi = 0; @@ -194,6 +183,8 @@ int fcgi_init(void) { if (!is_initialized) { + zend_hash_init(&fcgi_mgmt_vars, 0, NULL, fcgi_free_mgmt_var_cb, 1); + fcgi_set_mgmt_var("FCGI_MPXS_CONNS", sizeof("FCGI_MPXS_CONNS")-1, "0", sizeof("0")-1); #ifdef _WIN32 # if 0 /* TODO: Support for TCP sockets */ @@ -260,6 +251,9 @@ void fcgi_shutdown(void) { + if (is_initialized) { + zend_hash_destroy(&fcgi_mgmt_vars); + } is_fastcgi = 0; } @@ -750,8 +744,13 @@ padding = hdr.paddingLength; } } else if (hdr.type == FCGI_GET_VALUES) { - int j; unsigned char *p = buf + sizeof(fcgi_header); + HashPosition pos; + char * str_index; + uint str_length; + ulong num_index; + int key_type; + zval ** value; if (safe_read(req, buf, len+padding) != len+padding) {
Re: [PHP-CVS] cvs: php-src(PHP_5_3) / NEWS /sapi/cgi cgi_main.c fastcgi.c fastcgi.h
Yeah, Dmitry could you please MFH. On 26-Aug-08, at 7:00 AM, Jani Taskinen wrote: Sounds like something that should go to PHP_5_2 branch also? --Jani Dmitry Stogov wrote: dmitry Tue Aug 26 09:56:09 2008 UTC Modified files: (Branch: PHP_5_3) /php-src NEWS /php-src/sapi/cgi cgi_main.c fastcgi.c fastcgi.h Log: Fixed bug #45786 (FastCGI process exited unexpectedly) http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.286&r2=1.2027.2.547.2.965.2.287&diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.547.2.965.2.286 php-src/NEWS:1.2027.2.547.2.965.2.287 --- php-src/NEWS:1.2027.2.547.2.965.2.286 Mon Aug 25 18:40:44 2008 +++ php-src/NEWSTue Aug 26 09:56:08 2008 @@ -27,6 +27,7 @@ relative time string. (Derick) - Fixed bug #45798 (sqlite3 doesn't notice if variable was bound). (Felipe) +- Fixed bug #45786 (FastCGI process exited unexpectedly). (Dmitry) - Fixed bug #45763 (mysqli::multi_query does not work with mysqlnd). (Johannes) - Fixed bug #45757 (FreeBSD4.11 build failure: failed include; stdint.h). (Hannes) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.25&r2=1.267.2.15.2.50.2.26&diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.25 php-src/ sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.26 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.25 Mon Aug 18 10:49:35 2008 +++ php-src/sapi/cgi/cgi_main.c Tue Aug 26 09:56:08 2008 @@ -21,7 +21,7 @@ + --+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.25 2008/08/18 10:49:35 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.26 2008/08/26 09:56:08 dmitry Exp $ */ #include "php.h" #include "php_globals.h" @@ -776,7 +776,7 @@ #ifndef PHP_WIN32 !parent && #endif - !fcgi_finish_request((fcgi_request*)SG(server_context))) { + !fcgi_finish_request((fcgi_request*)SG(server_context), 0)) { php_handle_aborted_connection(); } } else { @@ -1914,7 +1914,7 @@ get path_translated */ if (php_request_startup(TSRMLS_C) == FAILURE) { if (fastcgi) { - fcgi_finish_request(&request); + fcgi_finish_request(&request, 1); } SG(server_context) = NULL; php_module_shutdown(TSRMLS_C); @@ -2056,7 +2056,7 @@ /* only fastcgi will get here */ requests++; if (max_requests && (requests == max_requests)) { - fcgi_finish_request(&request); + fcgi_finish_request(&request, 1); if (bindpath) { free(bindpath); } http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.4.2.13.2.28.2.5&r2=1.4.2.13.2.28.2.6&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.5 php-src/sapi/ cgi/fastcgi.c:1.4.2.13.2.28.2.6 --- php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.5 Mon Aug 18 10:49:35 2008 +++ php-src/sapi/cgi/fastcgi.c Tue Aug 26 09:56:08 2008 @@ -16,7 +16,7 @@ + --+ */ -/* $Id: fastcgi.c,v 1.4.2.13.2.28.2.5 2008/08/18 10:49:35 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.4.2.13.2.28.2.6 2008/08/26 09:56:08 dmitry Exp $ */ #include "php.h" #include "fastcgi.h" @@ -662,6 +662,7 @@ unsigned char buf[FCGI_MAX_LENGTH+8]; req->keep = 0; + req->closed = 0; req->in_len = 0; req->out_hdr = NULL; req->out_pos = req->out_buf; @@ -886,7 +887,6 @@ HANDLE pipe; OVERLAPPED ov; #endif - fcgi_finish_request(req); while (1) { if (req->fd < 0) { @@ -1177,13 +1177,16 @@ return len; } -int fcgi_finish_request(fcgi_request *req) +int fcgi_finish_request(fcgi_request *req, int force_close) { int ret = 1; if (req->fd >= 0) { - ret = fcgi_flush(req, 1); - fcgi_close(req, 0, 1); + if (!req->closed) { + ret = fcgi_flush(req, 1); + req->closed = 1; + } + fcgi_close(req, force_close, 1); } return ret; } http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.h?r1=1.2.2.4.2.5.2.2&r2=1.2.2.4.2.5.2.3&diff_format=u Index: php-src/sapi/cgi/fastcgi.h diff -u php-src/sapi/cgi/fastcgi.h:1.2.2.4.2.5.2.2 php-src/sapi/cgi/ fastcgi.h:1.2.2.4.2.5.2.3 --- php-src/sapi/cgi/fastcgi.h:1.2.2.4
Re: [PHP-CVS] cvs: php-src(PHP_5_3) / NEWS /sapi/cgi cgi_main.c fastcgi.c fastcgi.h
Sounds like something that should go to PHP_5_2 branch also? --Jani Dmitry Stogov wrote: dmitry Tue Aug 26 09:56:09 2008 UTC Modified files: (Branch: PHP_5_3) /php-src NEWS /php-src/sapi/cgi cgi_main.c fastcgi.c fastcgi.h Log: Fixed bug #45786 (FastCGI process exited unexpectedly) http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.286&r2=1.2027.2.547.2.965.2.287&diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.547.2.965.2.286 php-src/NEWS:1.2027.2.547.2.965.2.287 --- php-src/NEWS:1.2027.2.547.2.965.2.286 Mon Aug 25 18:40:44 2008 +++ php-src/NEWSTue Aug 26 09:56:08 2008 @@ -27,6 +27,7 @@ relative time string. (Derick) - Fixed bug #45798 (sqlite3 doesn't notice if variable was bound). (Felipe) +- Fixed bug #45786 (FastCGI process exited unexpectedly). (Dmitry) - Fixed bug #45763 (mysqli::multi_query does not work with mysqlnd). (Johannes) - Fixed bug #45757 (FreeBSD4.11 build failure: failed include; stdint.h). (Hannes) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.25&r2=1.267.2.15.2.50.2.26&diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.25 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.26 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.25Mon Aug 18 10:49:35 2008 +++ php-src/sapi/cgi/cgi_main.c Tue Aug 26 09:56:08 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.25 2008/08/18 10:49:35 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.26 2008/08/26 09:56:08 dmitry Exp $ */ #include "php.h" #include "php_globals.h" @@ -776,7 +776,7 @@ #ifndef PHP_WIN32 !parent && #endif - !fcgi_finish_request((fcgi_request*)SG(server_context))) { + !fcgi_finish_request((fcgi_request*)SG(server_context), 0)) { php_handle_aborted_connection(); } } else { @@ -1914,7 +1914,7 @@ get path_translated */ if (php_request_startup(TSRMLS_C) == FAILURE) { if (fastcgi) { - fcgi_finish_request(&request); + fcgi_finish_request(&request, 1); } SG(server_context) = NULL; php_module_shutdown(TSRMLS_C); @@ -2056,7 +2056,7 @@ /* only fastcgi will get here */ requests++; if (max_requests && (requests == max_requests)) { - fcgi_finish_request(&request); + fcgi_finish_request(&request, 1); if (bindpath) { free(bindpath); } http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.4.2.13.2.28.2.5&r2=1.4.2.13.2.28.2.6&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.5 php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.6 --- php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.5Mon Aug 18 10:49:35 2008 +++ php-src/sapi/cgi/fastcgi.c Tue Aug 26 09:56:08 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.4.2.13.2.28.2.5 2008/08/18 10:49:35 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.4.2.13.2.28.2.6 2008/08/26 09:56:08 dmitry Exp $ */ #include "php.h" #include "fastcgi.h" @@ -662,6 +662,7 @@ unsigned char buf[FCGI_MAX_LENGTH+8]; req->keep = 0; + req->closed = 0; req->in_len = 0; req->out_hdr = NULL; req->out_pos = req->out_buf; @@ -886,7 +887,6 @@ HANDLE pipe; OVERLAPPED ov; #endif - fcgi_finish_request(req); while (1) { if (req->fd < 0) { @@ -1177,13 +1177,16 @@ return len; } -int fcgi_finish_request(fcgi_request *req) +int fcgi_finish_request(fcgi_request *req, int force_close) { int ret = 1; if (req->fd >= 0) { - ret = fcgi_flush(req, 1); - fcgi_close(req, 0, 1); + if (!req->closed) { + ret = fcgi_flush(req, 1); + req->closed = 1; + } + fcgi_close(req, force_close, 1); } return ret; } http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.h?r1=1.2.2.4.2.5.2.2&r2=1.2.2.4.2.5.2.3&diff_format=u Index: php-src/sapi/cgi/fastcgi.h diff -u php-src/sapi/cgi/fastcgi.h:1.2.2.4.2.5.2.2 php-src/sapi/cgi/fastcgi.h:1.2.2.4.2.5.2.3 --- php-src/sapi/cgi/fastcgi.h:1.2.2.4.2.5.2.2 Mon Aug 18 10:49:35 2008 +++ php-src/sapi/cgi/fastcgi.h Tue Aug 26 09:
[PHP-CVS] cvs: php-src(PHP_5_3) / NEWS /sapi/cgi cgi_main.c fastcgi.c fastcgi.h
dmitry Tue Aug 26 09:56:09 2008 UTC Modified files: (Branch: PHP_5_3) /php-srcNEWS /php-src/sapi/cgi cgi_main.c fastcgi.c fastcgi.h Log: Fixed bug #45786 (FastCGI process exited unexpectedly) http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.286&r2=1.2027.2.547.2.965.2.287&diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.547.2.965.2.286 php-src/NEWS:1.2027.2.547.2.965.2.287 --- php-src/NEWS:1.2027.2.547.2.965.2.286 Mon Aug 25 18:40:44 2008 +++ php-src/NEWSTue Aug 26 09:56:08 2008 @@ -27,6 +27,7 @@ relative time string. (Derick) - Fixed bug #45798 (sqlite3 doesn't notice if variable was bound). (Felipe) +- Fixed bug #45786 (FastCGI process exited unexpectedly). (Dmitry) - Fixed bug #45763 (mysqli::multi_query does not work with mysqlnd). (Johannes) - Fixed bug #45757 (FreeBSD4.11 build failure: failed include; stdint.h). (Hannes) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.50.2.25&r2=1.267.2.15.2.50.2.26&diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.25 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.26 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.50.2.25Mon Aug 18 10:49:35 2008 +++ php-src/sapi/cgi/cgi_main.c Tue Aug 26 09:56:08 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.25 2008/08/18 10:49:35 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.50.2.26 2008/08/26 09:56:08 dmitry Exp $ */ #include "php.h" #include "php_globals.h" @@ -776,7 +776,7 @@ #ifndef PHP_WIN32 !parent && #endif - !fcgi_finish_request((fcgi_request*)SG(server_context))) { + !fcgi_finish_request((fcgi_request*)SG(server_context), 0)) { php_handle_aborted_connection(); } } else { @@ -1914,7 +1914,7 @@ get path_translated */ if (php_request_startup(TSRMLS_C) == FAILURE) { if (fastcgi) { - fcgi_finish_request(&request); + fcgi_finish_request(&request, 1); } SG(server_context) = NULL; php_module_shutdown(TSRMLS_C); @@ -2056,7 +2056,7 @@ /* only fastcgi will get here */ requests++; if (max_requests && (requests == max_requests)) { - fcgi_finish_request(&request); + fcgi_finish_request(&request, 1); if (bindpath) { free(bindpath); } http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.4.2.13.2.28.2.5&r2=1.4.2.13.2.28.2.6&diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.5 php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.6 --- php-src/sapi/cgi/fastcgi.c:1.4.2.13.2.28.2.5Mon Aug 18 10:49:35 2008 +++ php-src/sapi/cgi/fastcgi.c Tue Aug 26 09:56:08 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.4.2.13.2.28.2.5 2008/08/18 10:49:35 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.4.2.13.2.28.2.6 2008/08/26 09:56:08 dmitry Exp $ */ #include "php.h" #include "fastcgi.h" @@ -662,6 +662,7 @@ unsigned char buf[FCGI_MAX_LENGTH+8]; req->keep = 0; + req->closed = 0; req->in_len = 0; req->out_hdr = NULL; req->out_pos = req->out_buf; @@ -886,7 +887,6 @@ HANDLE pipe; OVERLAPPED ov; #endif - fcgi_finish_request(req); while (1) { if (req->fd < 0) { @@ -1177,13 +1177,16 @@ return len; } -int fcgi_finish_request(fcgi_request *req) +int fcgi_finish_request(fcgi_request *req, int force_close) { int ret = 1; if (req->fd >= 0) { - ret = fcgi_flush(req, 1); - fcgi_close(req, 0, 1); + if (!req->closed) { + ret = fcgi_flush(req, 1); + req->closed = 1; + } + fcgi_close(req, force_close, 1); } return ret; } http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.h?r1=1.2.2.4.2.5.2.2&r2=1.2.2.4.2.5.2.3&diff_format=u Index: php-src/sapi/cgi/fastcgi.h diff -u php-src/sapi/cgi/fastcgi.h:1.2.2.4.2.5.2.2 php-src/sapi/cgi/fastcgi.h:1.2.2.4.2.5.2.3 --- php-src/sapi/cgi/fastcgi.h:1.2.2.4.2.5.2.2 Mon Aug 18 10:49:35 2008 +++ php-src/sapi/cgi/fastcgi.h Tue Aug 26 09:56:08 2008 @@ -16,7 +16,7 @@ +-