support body_as_file in cgi plugin

This commit is contained in:
roberto@netbsd64
2012-01-06 22:21:08 +01:00
parent 4650d2edbb
commit 5e8d38d8bc
+13 -2
View File
@@ -703,13 +703,24 @@ clear:
// close all the fd except wsgi_req->poll.fd and 2;
for(i=0;i< (int)uwsgi.max_fd;i++) {
if (wsgi_req->async_post) {
if (fileno(wsgi_req->async_post) == i) {
continue;
}
}
if (i != wsgi_req->poll.fd && i != 2 && i != cgi_pipe[1]) {
close(i);
}
}
// now map wsgi_req->poll.fd to 0 & cgi_pipe[1] to 1
if (wsgi_req->poll.fd != 0) {
// now map wsgi_req->poll.fd (or async_post) to 0 & cgi_pipe[1] to 1
if (wsgi_req->async_post) {
if (fileno(wsgi_req->async_post) != 0) {
dup2(fileno(wsgi_req->async_post), 0);
fclose(wsgi_req->async_post);
}
}
else if (wsgi_req->poll.fd != 0) {
dup2(wsgi_req->poll.fd, 0);
close(wsgi_req->poll.fd);
}