[PATCH]HTTP/2 connection not properly closing during graceful shutdown

Roman Arutyunyan arut at nginx.com
Thu Jul 11 09:33:43 UTC 2024


Hi,

On Mon, May 06, 2024 at 11:14:24AM +0800, kasei at kasei.im wrote:
> Hello,
> 
> Thanks for your confirmation and explanations.
> 
> The following is a modified patch. In my test it would send GOAWAY(on
> stream id 0), same as the previous one, but call
> ngx_http_v2_finalize_connection instead of set c->close.
> 
> # HG changeset patch
> # User Kasei Wang <kasei at kasei.im>
> # Date 1714965008 -28800
> #      Mon May 06 11:10:08 2024 +0800
> # Branch help
> # Node ID 70b6b6b69e6fd3a0d03de004acf45bad16b03a9c
> # Parent  8618e4d900cc71082fbe7dc72af087937d64faf5
> HTTP/2: close http2 connections initialized during graceful shutdown.

I'd remove 'http2' to fulfill the 67 character restriction.
 
> In some rare cases, a HTTP/2 connections can be initialized during a
> graceful shutdown. Now close such an connection to avoid unexcepted
> delays in the graceful shutdown.
> 
> diff -r 8618e4d900cc -r 70b6b6b69e6f src/http/v2/ngx_http_v2.c
> --- a/src/http/v2/ngx_http_v2.c Tue Apr 16 18:27:50 2024 +0400
> +++ b/src/http/v2/ngx_http_v2.c Mon May 06 11:10:08 2024 +0800
> @@ -304,6 +304,11 @@
>      c->idle = 1;
>      ngx_reusable_connection(c, 0);
> 
> +    if (ngx_exiting) {
> +        ngx_http_v2_finalize_connection(h2c, NGX_HTTP_V2_NO_ERROR);
> +        return;
> +    }

I'd move this up a few lines.

> +
>      if (c->buffer) {
>          p = c->buffer->pos;
>          end = c->buffer->last;

Otherwise looks fine, thanks.  And sorry for the delay.

--
Roman Arutyunyan


More information about the nginx-devel mailing list