fix blocked CGI read

This commit is contained in:
Sergey Lyubka committed 2010-11-15 10:41:17 +01:00
1 parent f23d9ff3b0
commit 1de7fef760
3 files changed
+19 -18

No files matched your search

+4 -1
View File
@@ -1305,7 +1305,10 @@ static int pull(FILE *fp, SOCKET sock, SSL *ssl, char *buf, int len) {
if (ssl != NULL) {
nread = SSL_read(ssl, buf, len);
} else if (fp != NULL) {
nread = fread(buf, 1, (size_t) len, fp);
// Use read() instead of fread(), because if we're reading from the CGI
// pipe, fread() may block until IO buffer is filled up. We cannot afford
// to block and must pass all read bytes immediately to the client.
nread = read(fileno(fp), buf, (size_t) len);
if (ferror(fp))
nread = -1;
} else {