Skip to content

Commit

Permalink
Fixed bug #67583
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nikic committed Jan 7, 2017
1 parent f346bd6 commit a46bbdd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
14 changes: 10 additions & 4 deletions main/fastcgi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions main/fastcgi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions sapi/fpm/fpm/fpm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit a46bbdd

Please sign in to comment.