From d663b9cc774f0667203c383da5c6408b68209086 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 25 Aug 2010 13:48:16 +0000 Subject: [PATCH] Don't try to read the rest of malformed FCGI requests, close immediately. It saves one recv() call for proper FCGI request. --- sapi/cgi/fastcgi.c | 10 ++++++---- 1 file 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 -- 2.40.0