From 952c4ce854fec68a7ac78c9fe3a0fc5b4c9dc1e9 Mon Sep 17 00:00:00 2001 From: Roberto De Ioris Date: Sat, 22 Feb 2014 11:13:50 +0100 Subject: [PATCH] minor fixes in non-blocking reads --- core/io.c | 2 ++ plugins/cgi/cgi_plugin.c | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/core/io.c b/core/io.c index 03560b86..6ff1a0c5 100644 --- a/core/io.c +++ b/core/io.c @@ -967,6 +967,7 @@ int uwsgi_read_nb(int fd, char *buf, size_t remains, int timeout) { ssize_t uwsgi_read_true_nb(int fd, char *buf, size_t len, int timeout) { int ret; + errno = 0; ssize_t rlen = read(fd, buf, len); if (rlen > 0) { return rlen; @@ -979,6 +980,7 @@ ssize_t uwsgi_read_true_nb(int fd, char *buf, size_t len, int timeout) { wait: ret = uwsgi.wait_read_hook(fd, timeout); if (ret > 0) { + errno = 0; rlen = read(fd, buf, len); if (rlen > 0) { return rlen; diff --git a/plugins/cgi/cgi_plugin.c b/plugins/cgi/cgi_plugin.c index 3cf5e641..38d0d5ea 100644 --- a/plugins/cgi/cgi_plugin.c +++ b/plugins/cgi/cgi_plugin.c @@ -681,19 +681,16 @@ static int uwsgi_cgi_run(struct wsgi_request *wsgi_req, char *docroot, size_t do ssize_t rlen = 0; char *buf = uwsgi_request_body_read(wsgi_req, 8192, &rlen); if (!buf) { - close(post_pipe[1]); goto clear2; } if (buf == uwsgi.empty) break; // write data to the node if (uwsgi_write_true_nb(post_pipe[1], buf, rlen, uc.timeout)) { - close(post_pipe[1]); goto clear2; } remains -= rlen; } - close(post_pipe[1]); // wait for data char *buf = uwsgi_malloc(uc.buffer_size);