Welcome! Log In Create A New Profile

Advanced

[nginx] Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).

Valentin Bartenev
September 16, 2013 10:36AM
details: http://hg.nginx.org/nginx/rev/ef3d094bb6d3
branches:
changeset: 5374:ef3d094bb6d3
user: Valentin Bartenev <vbart@nginx.com>
date: Mon Sep 16 18:33:39 2013 +0400
description:
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:

src/http/ngx_http_request.c | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)

diffs (37 lines):

diff -r 46bdbca10dfc -r ef3d094bb6d3 src/http/ngx_http_request.c
--- a/src/http/ngx_http_request.c Mon Sep 16 18:33:39 2013 +0400
+++ b/src/http/ngx_http_request.c Mon Sep 16 18:33:39 2013 +0400
@@ -2694,6 +2694,33 @@ ngx_http_test_reading(ngx_http_request_t

#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) {

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).

Valentin Bartenev 793 September 16, 2013 10:36AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 159
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready