summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2006-04-26 11:08:10 +0000
committerDmitry Stogov <dmitry@php.net>2006-04-26 11:08:10 +0000
commitbbda630ed93e1d9c29ee71581c2c8d8f0664339e (patch)
tree17db481a9879fa54f687070e3c597777522a95d2
parentaf11e1d592709e1fff726e3121332890acabbc17 (diff)
downloadphp-git-bbda630ed93e1d9c29ee71581c2c8d8f0664339e.tar.gz
Fixed bug #37205 (Serving binary content/images fails with "comm with server aborted" FastCGI err)
-rw-r--r--NEWS2
-rw-r--r--sapi/cgi/fastcgi.c26
2 files changed, 24 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index d2972c810f..54a84aafea 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,8 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? Apr 2006, PHP 5.1.3RC4
+- Fixed bug #37205 (Serving binary content/images fails with "comm with server
+ aborted" FastCGI err). (Dmitry)
- Fixed bug #37192 (cc may complain about non-constant initializers in
hash_adler.c). (Mike)
- Fixed bug #37191 (chmod takes off sticky bit when safe_mode is On). (Tony)
diff --git a/sapi/cgi/fastcgi.c b/sapi/cgi/fastcgi.c
index 727c48a112..afa5271d0e 100644
--- a/sapi/cgi/fastcgi.c
+++ b/sapi/cgi/fastcgi.c
@@ -618,8 +618,12 @@ static inline void fcgi_close(fcgi_request *req, int force, int destroy)
RevertToSelf();
}
#else
+#if 1
+ shutdown(req->fd, 2);
+#else
close(req->fd);
#endif
+#endif
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);
req->out_pos += len - limit;
} else {
- int pad = ((len + 7) & ~7) - len;
+ int pos = 0;
+ int pad;
+ close_packet(req);
+ while ((len - pos) > 0xffff) {
+ open_packet(req, type);
+ fcgi_make_header(req->out_hdr, type, req->id, 0xfff8);
+ req->out_hdr = NULL;
+ fcgi_flush(req, 0);
+ 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;
- close_packet(req);
open_packet(req, type);
- fcgi_make_header(req->out_hdr, type, req->id, len - rest);
+ 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, len - rest) != len - rest) {
+ if (safe_write(req, str + pos, (len - pos) - rest) != (len - pos) - rest) {
req->keep = 0;
return -1;
}