Skip to content

Commit bb2ab75

Browse files
committed
Merge branch 'PHP-7.0' into PHP-7.1
2 parents 201e56c + a46bbdd commit bb2ab75

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

main/fastcgi.c

+14-8
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ struct _fcgi_request {
216216
#ifdef TCP_NODELAY
217217
int nodelay;
218218
#endif
219-
int closed;
219+
int ended;
220220
int in_len;
221221
int in_pad;
222222

@@ -1045,7 +1045,7 @@ static int fcgi_read_request(fcgi_request *req)
10451045
unsigned char buf[FCGI_MAX_LENGTH+8];
10461046

10471047
req->keep = 0;
1048-
req->closed = 0;
1048+
req->ended = 0;
10491049
req->in_len = 0;
10501050
req->out_hdr = NULL;
10511051
req->out_pos = req->out_buf;
@@ -1506,15 +1506,15 @@ static inline void close_packet(fcgi_request *req)
15061506
}
15071507
}
15081508

1509-
int fcgi_flush(fcgi_request *req, int close)
1509+
int fcgi_flush(fcgi_request *req, int end)
15101510
{
15111511
int len;
15121512

15131513
close_packet(req);
15141514

15151515
len = (int)(req->out_pos - req->out_buf);
15161516

1517-
if (close) {
1517+
if (end) {
15181518
fcgi_end_request_rec *rec = (fcgi_end_request_rec*)(req->out_pos);
15191519

15201520
fcgi_make_header(&rec->hdr, FCGI_END_REQUEST, req->id, sizeof(fcgi_end_request));
@@ -1648,15 +1648,21 @@ int fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int l
16481648
return len;
16491649
}
16501650

1651+
int fcgi_end(fcgi_request *req) {
1652+
int ret = 1;
1653+
if (!req->ended) {
1654+
ret = fcgi_flush(req, 1);
1655+
req->ended = 1;
1656+
}
1657+
return ret;
1658+
}
1659+
16511660
int fcgi_finish_request(fcgi_request *req, int force_close)
16521661
{
16531662
int ret = 1;
16541663

16551664
if (req->fd >= 0) {
1656-
if (!req->closed) {
1657-
ret = fcgi_flush(req, 1);
1658-
req->closed = 1;
1659-
}
1665+
ret = fcgi_end(req);
16601666
fcgi_close(req, force_close, 1);
16611667
}
16621668
return ret;

main/fastcgi.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ void fcgi_loadenv(fcgi_request *req, fcgi_apply_func load_func, zval *array);
118118
int fcgi_read(fcgi_request *req, char *str, int len);
119119

120120
int fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int len);
121-
int fcgi_flush(fcgi_request *req, int close);
121+
int fcgi_flush(fcgi_request *req, int end);
122+
int fcgi_end(fcgi_request *req);
122123

123124
#ifdef PHP_WIN32
124125
void fcgi_impersonate(void);

sapi/fpm/fpm/fpm_main.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -1534,11 +1534,10 @@ PHP_FUNCTION(fastcgi_finish_request) /* {{{ */
15341534
fcgi_request *request = (fcgi_request*) SG(server_context);
15351535

15361536
if (!fcgi_is_closed(request)) {
1537-
15381537
php_output_end_all();
15391538
php_header();
15401539

1541-
fcgi_flush(request, 1);
1540+
fcgi_end(request);
15421541
fcgi_close(request, 0, 0);
15431542
RETURN_TRUE;
15441543
}

0 commit comments

Comments
 (0)