Mercurial > hg > nginx
changeset 6506:dc1ae0056a1e
Fixed small inconsistency in handling EOF among receive functions.
Now all functions always drop the ready flag in this case.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Fri, 08 Apr 2016 16:39:49 +0300 |
parents | 5ad379eab6fa |
children | 8ee94ecd3a50 |
files | src/os/unix/ngx_readv_chain.c src/os/unix/ngx_recv.c |
diffstat | 2 files changed, 41 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/src/os/unix/ngx_readv_chain.c Fri Apr 08 16:38:42 2016 +0300 +++ b/src/os/unix/ngx_readv_chain.c Fri Apr 08 16:39:49 2016 +0300 @@ -106,7 +106,27 @@ do { n = readv(c->fd, (struct iovec *) vec.elts, vec.nelts); - if (n >= 0) { + if (n == 0) { + rev->ready = 0; + rev->eof = 1; + +#if (NGX_HAVE_KQUEUE) + + /* + * on FreeBSD readv() may return 0 on closed socket + * even if kqueue reported about available data + */ + + if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) { + rev->available = 0; + } + +#endif + + return 0; + } + + if (n > 0) { #if (NGX_HAVE_KQUEUE) @@ -115,7 +135,7 @@ /* * rev->available may be negative here because some additional - * bytes may be received between kevent() and recv() + * bytes may be received between kevent() and readv() */ if (rev->available <= 0) { @@ -128,37 +148,15 @@ } } - if (n == 0) { - - /* - * on FreeBSD recv() may return 0 on closed socket - * even if kqueue reported about available data - */ - -#if 0 - ngx_log_error(NGX_LOG_ALERT, c->log, 0, - "readv() returned 0 while kevent() reported " - "%d available bytes", rev->available); -#endif - - rev->ready = 0; - rev->eof = 1; - rev->available = 0; - } - return n; } -#endif /* NGX_HAVE_KQUEUE */ +#endif if (n < size && !(ngx_event_flags & NGX_USE_GREEDY_EVENT)) { rev->ready = 0; } - if (n == 0) { - rev->eof = 1; - } - return n; }
--- a/src/os/unix/ngx_recv.c Fri Apr 08 16:38:42 2016 +0300 +++ b/src/os/unix/ngx_recv.c Fri Apr 08 16:39:49 2016 +0300 @@ -54,7 +54,24 @@ ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, "recv: fd:%d %z of %uz", c->fd, n, size); - if (n >= 0) { + if (n == 0) { + rev->ready = 0; + rev->eof = 1; + + /* + * on FreeBSD recv() may return 0 on closed socket + * even if kqueue reported about available data + */ + + if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) { + rev->available = 0; + } + + return 0; + } + + if (n > 0) { + if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) { rev->available -= n; @@ -73,18 +90,6 @@ } } - if (n == 0) { - - /* - * on FreeBSD recv() may return 0 on closed socket - * even if kqueue reported about available data - */ - - rev->ready = 0; - rev->eof = 1; - rev->available = 0; - } - return n; } @@ -94,10 +99,6 @@ rev->ready = 0; } - if (n == 0) { - rev->eof = 1; - } - return n; }