Skip to content

Commit a5ba93e

Browse files
committed
FPM: fastcgi_finish_request supports force close keepalived connection
1 parent 8276560 commit a5ba93e

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

sapi/fpm/fpm/fpm_main.c

+9-4
Original file line numberDiff line numberDiff line change
@@ -1488,18 +1488,23 @@ static PHP_MINFO_FUNCTION(cgi)
14881488

14891489
PHP_FUNCTION(fastcgi_finish_request) /* {{{ */
14901490
{
1491+
bool close_conn = 1;
14911492
fcgi_request *request = (fcgi_request*) SG(server_context);
14921493

1493-
if (zend_parse_parameters_none() == FAILURE) {
1494-
RETURN_THROWS();
1495-
}
1494+
ZEND_PARSE_PARAMETERS_START(0, 1)
1495+
Z_PARAM_OPTIONAL
1496+
Z_PARAM_BOOL(close_conn)
1497+
ZEND_PARSE_PARAMETERS_END();
14961498

14971499
if (!fcgi_is_closed(request)) {
14981500
php_output_end_all();
14991501
php_header();
15001502

1503+
if (close_conn) {
1504+
fcgi_request_set_keep(request, 0);
1505+
}
15011506
fcgi_end(request);
1502-
fcgi_close(request, 0, 0);
1507+
fcgi_close(request, 0, close_conn);
15031508
RETURN_TRUE;
15041509
}
15051510

sapi/fpm/fpm/fpm_main.stub.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/** @generate-class-entries */
44

5-
function fastcgi_finish_request(): bool {}
5+
function fastcgi_finish_request(bool $close_conn = true): bool {}
66

77
function apache_request_headers(): array {}
88

sapi/fpm/fpm/fpm_main_arginfo.h

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)