aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_request.c
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2013-09-16 18:33:39 +0400
committerValentin Bartenev <vbart@nginx.com>2013-09-16 18:33:39 +0400
commita11050ea4e4fa0c6996f9115e04635723a642f5f (patch)
tree3bb6b134948d550019db246a80a9b0243da3bda2 /src/http/ngx_http_request.c
parent096678ced4995f43c0e1930a92061eaf497699c8 (diff)
downloadnginx-a11050ea4e4fa0c6996f9115e04635723a642f5f.tar.gz
nginx-a11050ea4e4fa0c6996f9115e04635723a642f5f.zip
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
This allows to detect client connection close with pending data when the ngx_http_test_reading() request event handler is set.
Diffstat (limited to 'src/http/ngx_http_request.c')
-rw-r--r--src/http/ngx_http_request.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 37efb2a52..1f6d246bc 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -2694,6 +2694,33 @@ ngx_http_test_reading(ngx_http_request_t *r)
#endif
+#if (NGX_HAVE_EPOLLRDHUP)
+
+ if ((ngx_event_flags & NGX_USE_EPOLL_EVENT) && rev->pending_eof) {
+ socklen_t len;
+
+ rev->eof = 1;
+ c->error = 1;
+
+ err = 0;
+ len = sizeof(ngx_err_t);
+
+ /*
+ * BSDs and Linux return 0 and set a pending error in err
+ * Solaris returns -1 and sets errno
+ */
+
+ if (getsockopt(c->fd, SOL_SOCKET, SO_ERROR, (void *) &err, &len)
+ == -1)
+ {
+ err = ngx_errno;
+ }
+
+ goto closed;
+ }
+
+#endif
+
n = recv(c->fd, buf, 1, MSG_PEEK);
if (n == 0) {