[nginx] HTTP/2: handling of connections initialized during shutd...

Maxim Dounin mdounin at mdounin.ru
Tue May 28 17:54:46 UTC 2024


details:   http://freenginx.org/hg/nginx/rev/4a0cd107c0f1
branches:  
changeset: 9277:4a0cd107c0f1
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Tue May 28 20:43:50 2024 +0300
description:
HTTP/2: handling of connections initialized during shutdown.

If an HTTP/2 connection opened before a graceful shutdown, but
ngx_http_v2_init() is called after idle connections were closed, such
a connection ended up being open till closed by the client (or up to
keepalive_time), delaying shutdown.

With this change, such connections are allowed to serve just one request,
much like it happens in HTTP/1.x, and closed afterwards.

Reported by Kasei Wang,
https://freenginx.org/pipermail/nginx-devel/2024-May/000277.html

diffstat:

 src/http/v2/ngx_http_v2.c |  3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diffs (13 lines):

diff --git a/src/http/v2/ngx_http_v2.c b/src/http/v2/ngx_http_v2.c
--- a/src/http/v2/ngx_http_v2.c
+++ b/src/http/v2/ngx_http_v2.c
@@ -1336,7 +1336,8 @@ ngx_http_v2_state_headers(ngx_http_v2_co
     clcf = ngx_http_get_module_loc_conf(h2c->http_connection->conf_ctx,
                                         ngx_http_core_module);
 
-    if (clcf->keepalive_timeout == 0
+    if (ngx_exiting
+        || clcf->keepalive_timeout == 0
         || h2c->connection->requests >= clcf->keepalive_requests
         || ngx_current_msec - h2c->connection->start_time
            > clcf->keepalive_time)



More information about the nginx-devel mailing list