mirror of
https://github.com/php/php-src.git
synced 2025-08-20 01:14:28 +02:00
Fixed bug #37205 (Serving binary content/images fails with "comm with server aborted" FastCGI err)
This commit is contained in:
parent
80ac536d13
commit
8fbff809bd
1 changed files with 23 additions and 5 deletions
|
@ -617,8 +617,12 @@ static inline void fcgi_close(fcgi_request *req, int force, int destroy)
|
||||||
if (is_impersonate) {
|
if (is_impersonate) {
|
||||||
RevertToSelf();
|
RevertToSelf();
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#if 1
|
||||||
|
shutdown(req->fd, 2);
|
||||||
#else
|
#else
|
||||||
close(req->fd);
|
close(req->fd);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
req->fd = -1;
|
req->fd = -1;
|
||||||
}
|
}
|
||||||
|
@ -814,16 +818,30 @@ int fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int l
|
||||||
memcpy(req->out_pos, str + limit, len - limit);
|
memcpy(req->out_pos, str + limit, len - limit);
|
||||||
req->out_pos += len - limit;
|
req->out_pos += len - limit;
|
||||||
} else {
|
} else {
|
||||||
int pad = ((len + 7) & ~7) - len;
|
int pos = 0;
|
||||||
|
int pad;
|
||||||
rest = pad ? 8 - pad : 0;
|
|
||||||
|
|
||||||
close_packet(req);
|
close_packet(req);
|
||||||
|
while ((len - pos) > 0xffff) {
|
||||||
open_packet(req, type);
|
open_packet(req, type);
|
||||||
fcgi_make_header(req->out_hdr, type, req->id, len - rest);
|
fcgi_make_header(req->out_hdr, type, req->id, 0xfff8);
|
||||||
req->out_hdr = NULL;
|
req->out_hdr = NULL;
|
||||||
fcgi_flush(req, 0);
|
fcgi_flush(req, 0);
|
||||||
if (safe_write(req, str, len - rest) != len - rest) {
|
if (safe_write(req, str + pos, 0xfff8) != 0xfff8) {
|
||||||
|
req->keep = 0;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
pos += 0xfff8;
|
||||||
|
}
|
||||||
|
|
||||||
|
pad = (((len - pos) + 7) & ~7) - (len - pos);
|
||||||
|
rest = pad ? 8 - pad : 0;
|
||||||
|
|
||||||
|
open_packet(req, type);
|
||||||
|
fcgi_make_header(req->out_hdr, type, req->id, (len - pos) - rest);
|
||||||
|
req->out_hdr = NULL;
|
||||||
|
fcgi_flush(req, 0);
|
||||||
|
if (safe_write(req, str + pos, (len - pos) - rest) != (len - pos) - rest) {
|
||||||
req->keep = 0;
|
req->keep = 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue