Welcome! Log In Create A New Profile

Advanced

Re: [PATCH] Events: fixed EPOLLRDHUP with FIONREAD (ticket #2367)

Maxim Dounin
July 16, 2022 01:42AM
Hello!

On Fri, Jul 15, 2022 at 03:23:57PM +0300, Maxim Dounin wrote:

> # HG changeset patch
> # User Maxim Dounin <mdounin@mdounin.ru>
> # Date 1657887572 -10800
> # Fri Jul 15 15:19:32 2022 +0300
> # Node ID f3510cb959d1ae168e3458036d1606dcedffd212
> # Parent ae2d62bb12c00ebd014c147d7b37252ccfe72373
> 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.
>
> diff --git a/src/os/unix/ngx_readv_chain.c b/src/os/unix/ngx_readv_chain.c
> --- a/src/os/unix/ngx_readv_chain.c
> +++ b/src/os/unix/ngx_readv_chain.c
> @@ -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;
> }
> }

Already reviewed in #2367 comments, pushed to
http://mdounin.ru/hg/nginx/.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

[PATCH] Events: fixed EPOLLRDHUP with FIONREAD (ticket #2367)

Maxim Dounin 197 July 16, 2022 01:38AM

Re: [PATCH] Events: fixed EPOLLRDHUP with FIONREAD (ticket #2367)

Maxim Dounin 67 July 16, 2022 01:42AM



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

Online Users

Guests: 59
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready