Welcome! Log In Create A New Profile

Advanced

Re: [PATCH] Process events posted by ngx_close_idle_connections() immediately

Sergey Kandaurov
November 22, 2022 06:04PM
On Fri, Nov 18, 2022 at 07:33:02PM +0400, Roman Arutyunyan wrote:
> # HG changeset patch
> # User Roman Arutyunyan <arut@nginx.com>
> # Date 1668785498 -14400
> # Fri Nov 18 19:31:38 2022 +0400
> # Node ID c185d439cbaecfe8ec5deb0fadd1a6e9a769990b
> # Parent 17d6a537fb1bb587e4de22961bf5be5f0c648fa8
> Process events posted by ngx_close_idle_connections() immediately.
>
> Previously, if an event was posted by a read event handler, called by
> ngx_close_idle_connections(), that event was not processed until the next
> event loop iteration, which could happen after a timeout.
>
> diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c
> --- a/src/os/unix/ngx_process_cycle.c
> +++ b/src/os/unix/ngx_process_cycle.c
> @@ -736,6 +736,7 @@ ngx_worker_process_cycle(ngx_cycle_t *cy
> ngx_set_shutdown_timer(cycle);
> ngx_close_listening_sockets(cycle);
> ngx_close_idle_connections(cycle);
> + ngx_event_process_posted(cycle, &ngx_posted_events);
> }
> }
>
> diff --git a/src/os/win32/ngx_process_cycle.c b/src/os/win32/ngx_process_cycle.c
> --- a/src/os/win32/ngx_process_cycle.c
> +++ b/src/os/win32/ngx_process_cycle.c
> @@ -804,6 +804,7 @@ ngx_worker_thread(void *data)
> ngx_set_shutdown_timer(cycle);
> ngx_close_listening_sockets(cycle);
> ngx_close_idle_connections(cycle);
> + ngx_event_process_posted(cycle, &ngx_posted_events);
> }
> }
>

Looks good.

Just for the record:
although this change doesn't seem to have in-tree consumers
(in particular, GOAWAY is sent synchronously in HTTP/2 connections),
it allows to correctly close (in certain edge cases) QUIC connections,
and should be good in general. A different approach to instead close
idle connections using posted next events should also work but assumes
a read on connection that may not be read ready on graceful shutdown.
_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

[PATCH] Process events posted by ngx_close_idle_connections() immediately

Roman Arutyunyan 502 November 18, 2022 10:34AM

Re: [PATCH] Process events posted by ngx_close_idle_connections() immediately

Sergey Kandaurov 99 November 22, 2022 06:04PM

Re: [PATCH] Process events posted by ngx_close_idle_connections() immediately

Maxim Dounin 127 November 22, 2022 07:20PM



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

Online Users

Guests: 280
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready