diff options
author | SVN Migration <svn@php.net> | 2006-04-27 11:39:33 +0000 |
---|---|---|
committer | SVN Migration <svn@php.net> | 2006-04-27 11:39:33 +0000 |
commit | 0778c40868892f2751a3aa48a7ad3d4d3c4e68ad (patch) | |
tree | 7ec2340255f849007a9f367da0b078b04458b742 /sapi/cgi/fastcgi.c | |
parent | 3566fe4afd6ee2431d90ca917db1ed9f16e7b889 (diff) | |
download | php-git-php-5.1.3.tar.gz |
This commit was manufactured by cvs2svn to create tag 'php_5_1_3'.php-5.1.3
Diffstat (limited to 'sapi/cgi/fastcgi.c')
-rw-r--r-- | sapi/cgi/fastcgi.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/sapi/cgi/fastcgi.c b/sapi/cgi/fastcgi.c index afa5271d0e..571cdab772 100644 --- a/sapi/cgi/fastcgi.c +++ b/sapi/cgi/fastcgi.c @@ -441,6 +441,7 @@ static int fcgi_read_request(fcgi_request *req) unsigned char buf[FCGI_MAX_LENGTH+8]; req->keep = 0; + req->has_in = 0; req->in_len = 0; req->out_hdr = NULL; req->out_pos = req->out_buf; @@ -509,6 +510,15 @@ static int fcgi_read_request(fcgi_request *req) len = (hdr.contentLengthB1 << 8) | hdr.contentLengthB0; padding = hdr.paddingLength; } + if (safe_read(req, &hdr, sizeof(fcgi_header)) != sizeof(fcgi_header) || + hdr.version < FCGI_VERSION_1 || + hdr.type != FCGI_STDIN) { + req->keep = 0; + return 0; + } + req->in_len = (hdr.contentLengthB1 << 8) | hdr.contentLengthB0; + req->in_pad = hdr.paddingLength; + req->has_in = (req->in_len != 0); } else if (hdr.type == FCGI_GET_VALUES) { int i, j; int name_len; @@ -551,6 +561,9 @@ int fcgi_read(fcgi_request *req, char *str, int len) fcgi_header hdr; unsigned char buf[8]; + if (!req->has_in) { + return 0; + } n = 0; rest = len; while (rest > 0) { @@ -618,12 +631,8 @@ 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; } } @@ -857,8 +866,10 @@ int fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int l int fcgi_finish_request(fcgi_request *req) { - fcgi_flush(req, 1); - fcgi_close(req, 0, 1); + if (req->fd >= 0) { + fcgi_flush(req, 1); + fcgi_close(req, 0, 1); + } return 1; } |