]> granicus.if.org Git - php/commitdiff
Fixed bug #67583
authorNikita Popov <nikic@php.net>
Sat, 7 Jan 2017 21:51:18 +0000 (22:51 +0100)
committerNikita Popov <nikic@php.net>
Sat, 7 Jan 2017 21:53:28 +0000 (22:53 +0100)
As fcgi_request is an opaque struct as of PHP 7, expose a new API
function fcgi_end() which does fcgi_flush() with end=1 and checks/
sets the ->ended flag.

NEWS
main/fastcgi.c
main/fastcgi.h
sapi/fpm/fpm/fpm_main.c

diff --git a/NEWS b/NEWS
index ba821fd202cc42fa166210a54c743774b589e06e..8a297b98f221abe11cc90a5793fcd84e6bd1a198 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,10 @@ PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2017 PHP 7.0.16
 
+- FPM:
+  . Fixed bug #67583 (double fastcgi_end_request on max_children limit).
+    (Dmitry Saprykin)
+
 - OpenSSL:
   . Fixed bug #71519 (add serial hex to return value array). (xrobau)
 
index c52d222df5c5088ea7d153cd3da559b91d645341..dd7c7ddeb9bf3edc8d3bd61e9e8f8094c7412493 100644 (file)
@@ -1645,15 +1645,21 @@ int fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int l
        return len;
 }
 
+int fcgi_end(fcgi_request *req) {
+       int ret = 1;
+       if (!req->ended) {
+               ret = fcgi_flush(req, 1);
+               req->ended = 1;
+       }
+       return ret;
+}
+
 int fcgi_finish_request(fcgi_request *req, int force_close)
 {
        int ret = 1;
 
        if (req->fd >= 0) {
-               if (!req->ended) {
-                       ret = fcgi_flush(req, 1);
-                       req->ended = 1;
-               }
+               ret = fcgi_end(req);
                fcgi_close(req, force_close, 1);
        }
        return ret;
index fbc70c31cf2d1a66884f092ba35e4119e78688e9..bba64016d894ac163beee0dbf0062413793dbbbf 100644 (file)
@@ -119,6 +119,7 @@ int fcgi_read(fcgi_request *req, char *str, int len);
 
 int fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int len);
 int fcgi_flush(fcgi_request *req, int end);
+int fcgi_end(fcgi_request *req);
 
 #ifdef PHP_WIN32
 void fcgi_impersonate(void);
index 5e09877eefc89ff6290d34cda9f5b409385a2f46..3ab92b307042ed174d8f6de06dfe27a30ce54c5c 100644 (file)
@@ -1533,11 +1533,10 @@ PHP_FUNCTION(fastcgi_finish_request) /* {{{ */
        fcgi_request *request = (fcgi_request*) SG(server_context);
 
        if (!fcgi_is_closed(request)) {
-
                php_output_end_all();
                php_header();
 
-               fcgi_flush(request, 1);
+               fcgi_end(request);
                fcgi_close(request, 0, 0);
                RETURN_TRUE;
        }