summaryrefslogtreecommitdiff
path: root/sapi/cgi/fastcgi.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2010-08-25 13:48:16 +0000
committerDmitry Stogov <dmitry@php.net>2010-08-25 13:48:16 +0000
commitd663b9cc774f0667203c383da5c6408b68209086 (patch)
tree407b00f4de0ce8be23530624f43e2d8252c19d5a /sapi/cgi/fastcgi.c
parent7fc86e5cb49be6e5d88f466b2035ea8e9a563554 (diff)
downloadphp-git-d663b9cc774f0667203c383da5c6408b68209086.tar.gz
Don't try to read the rest of malformed FCGI requests, close immediately. It saves one recv() call for proper FCGI request.
Diffstat (limited to 'sapi/cgi/fastcgi.c')
-rw-r--r--sapi/cgi/fastcgi.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/sapi/cgi/fastcgi.c b/sapi/cgi/fastcgi.c
index e5fefb08cf..8d2d7a32cb 100644
--- a/sapi/cgi/fastcgi.c
+++ b/sapi/cgi/fastcgi.c
@@ -1084,19 +1084,21 @@ static inline void fcgi_close(fcgi_request *req, int force, int destroy)
DisconnectNamedPipe(pipe);
} else {
if (!force) {
- char buf[8];
+ fcgi_header buf;
shutdown(req->fd, 1);
- while (recv(req->fd, buf, sizeof(buf), 0) > 0) {}
+ /* read the last FCGI_STDIN header (it may be omitted) */
+ recv(req->fd, &buf, sizeof(buf), 0);
}
closesocket(req->fd);
}
#else
if (!force) {
- char buf[8];
+ fcgi_header buf;
shutdown(req->fd, 1);
- while (recv(req->fd, buf, sizeof(buf), 0) > 0) {}
+ /* read the last FCGI_STDIN header (it may be omitted) */
+ recv(req->fd, &buf, sizeof(buf), 0);
}
close(req->fd);
#endif