comparison src/os/unix/ngx_readv_chain.c @ 8058:f3510cb959d1

Events: fixed EPOLLRDHUP with FIONREAD (ticket #2367). When reading exactly rev->available bytes, rev->available might become 0 after FIONREAD usage introduction in efd71d49bde0. On the next call of ngx_readv_chain() on systems with EPOLLRDHUP this resulted in return without any actions, that is, with rev->ready set, and this in turn resulted in no timers set in event pipe, leading to socket leaks. Fix is to reset rev->ready in ngx_readv_chain() when returning due to rev->available being 0 with EPOLLRDHUP, much like it is already done in ngx_unix_recv(). This ensures that if rev->available will become 0, on systems with EPOLLRDHUP support appropriate EPOLLRDHUP-specific handling will happen on the next ngx_readv_chain() call. While here, also synced ngx_readv_chain() to match ngx_unix_recv() and reset rev->ready when returning due to rev->available being 0 with kqueue. This is mostly cosmetic change, as rev->ready is anyway reset when rev->available is set to 0.
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 15 Jul 2022 15:19:32 +0300
parents 5119c8150478
children
comparison
equal deleted inserted replaced
8057:ae2d62bb12c0 8058:f3510cb959d1
44 } 44 }
45 45
46 return 0; 46 return 0;
47 47
48 } else { 48 } else {
49 rev->ready = 0;
49 return NGX_AGAIN; 50 return NGX_AGAIN;
50 } 51 }
51 } 52 }
52 } 53 }
53 54
61 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, 62 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
62 "readv: eof:%d, avail:%d", 63 "readv: eof:%d, avail:%d",
63 rev->pending_eof, rev->available); 64 rev->pending_eof, rev->available);
64 65
65 if (rev->available == 0 && !rev->pending_eof) { 66 if (rev->available == 0 && !rev->pending_eof) {
67 rev->ready = 0;
66 return NGX_AGAIN; 68 return NGX_AGAIN;
67 } 69 }
68 } 70 }
69 71
70 #endif 72 #endif