diff options
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | sapi/cgi/cgi_main.c | 6 | ||||
-rw-r--r-- | sapi/cgi/fastcgi.c | 11 | ||||
-rw-r--r-- | sapi/cgi/fastcgi.h | 3 |
4 files changed, 13 insertions, 8 deletions
@@ -27,6 +27,7 @@ PHP NEWS 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) diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 608943e582..73fa419e6c 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -776,7 +776,7 @@ static int sapi_cgi_deactivate(TSRMLS_D) #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 @@ consult the installation file that came with this distribution, or visit \n\ 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 @@ fastcgi_request_done: /* 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); } diff --git a/sapi/cgi/fastcgi.c b/sapi/cgi/fastcgi.c index ac55672ef0..8315c0c472 100644 --- a/sapi/cgi/fastcgi.c +++ b/sapi/cgi/fastcgi.c @@ -662,6 +662,7 @@ static int fcgi_read_request(fcgi_request *req) 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 @@ int fcgi_accept_request(fcgi_request *req) HANDLE pipe; OVERLAPPED ov; #endif - fcgi_finish_request(req); while (1) { if (req->fd < 0) { @@ -1177,13 +1177,16 @@ int fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int l 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; } diff --git a/sapi/cgi/fastcgi.h b/sapi/cgi/fastcgi.h index 5dfa5d541c..b5c418138a 100644 --- a/sapi/cgi/fastcgi.h +++ b/sapi/cgi/fastcgi.h @@ -99,6 +99,7 @@ typedef struct _fcgi_request { int fd; int id; int keep; + int closed; int in_len; int in_pad; @@ -118,7 +119,7 @@ int fcgi_in_shutdown(void); int fcgi_listen(const char *path, int backlog); void fcgi_init_request(fcgi_request *req, int listen_socket); int fcgi_accept_request(fcgi_request *req); -int fcgi_finish_request(fcgi_request *req); +int fcgi_finish_request(fcgi_request *req, int force_close); char* fcgi_getenv(fcgi_request *req, const char* var, int var_len); char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val); |