Properly read any remaining data when closing FastCGI socket

This commit is contained in:
Robin McCorkell 2016-01-29 15:14:08 +00:00 committed by Xinchen Hui
parent ae122bf7ad
commit 7806553fd3

View file

@ -1287,11 +1287,11 @@ void fcgi_close(fcgi_request *req, int force, int destroy)
} }
#else #else
if (!force) { if (!force) {
fcgi_header buf; char buf[8];
shutdown(req->fd, 1); shutdown(req->fd, 1);
/* read the last FCGI_STDIN header (it may be omitted) */ /* read any remaining data, it may be omitted */
recv(req->fd, (char *)(&buf), sizeof(buf), 0); while (recv(req->fd, buf, sizeof(buf), 0) > 0) {}
} }
close(req->fd); close(req->fd);
#endif #endif