aboutsummaryrefslogtreecommitdiff
path: root/src/os/unix/ngx_readv_chain.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/os/unix/ngx_readv_chain.c')
-rw-r--r--src/os/unix/ngx_readv_chain.c48
1 files changed, 23 insertions, 25 deletions
diff --git a/src/os/unix/ngx_readv_chain.c b/src/os/unix/ngx_readv_chain.c
index 9953782d6..981521f65 100644
--- a/src/os/unix/ngx_readv_chain.c
+++ b/src/os/unix/ngx_readv_chain.c
@@ -106,7 +106,27 @@ ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain, off_t limit)
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 @@ ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain, off_t limit)
/*
* 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 @@ ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain, off_t limit)
}
}
- 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;
}