[nginx] Events: fixed EPOLLRDHUP with FIONREAD (ticket #2367).
Sergey Kandaurov
pluknet at nginx.com
Sun Jul 17 08:05:56 UTC 2022
details: https://hg.nginx.org/nginx/rev/f3510cb959d1
branches:
changeset: 8058:f3510cb959d1
user: Maxim Dounin <mdounin at mdounin.ru>
date: Fri Jul 15 15:19:32 2022 +0300
description:
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.
diffstat:
src/os/unix/ngx_readv_chain.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diffs (19 lines):
diff -r ae2d62bb12c0 -r f3510cb959d1 src/os/unix/ngx_readv_chain.c
--- a/src/os/unix/ngx_readv_chain.c Fri Jul 15 07:01:44 2022 +0300
+++ b/src/os/unix/ngx_readv_chain.c Fri Jul 15 15:19:32 2022 +0300
@@ -46,6 +46,7 @@ ngx_readv_chain(ngx_connection_t *c, ngx
return 0;
} else {
+ rev->ready = 0;
return NGX_AGAIN;
}
}
@@ -63,6 +64,7 @@ ngx_readv_chain(ngx_connection_t *c, ngx
rev->pending_eof, rev->available);
if (rev->available == 0 && !rev->pending_eof) {
+ rev->ready = 0;
return NGX_AGAIN;
}
}
More information about the nginx-devel
mailing list