[PATCH 3 of 6] QUIC: call shutdown() callback only after handshake completion

Roman Arutyunyan arut at nginx.com
Thu Sep 14 10:17:06 UTC 2023


# HG changeset patch
# User Roman Arutyunyan <arut at nginx.com>
# Date 1694613709 -14400
#      Wed Sep 13 18:01:49 2023 +0400
# Node ID 51166a8f35ba880415ddc2bf2745012a8d4cea34
# Parent  6d3ca6f8db357a1db267978f730875e51e87c608
QUIC: call shutdown() callback only after handshake completion.

Previously the callback could be called while QUIC handshake was in progress
and, what's more important, before the init() callback.  Now it's postponed
after init().

This change is a preparation to postponing HTTP/3 session creation to init().

diff --git a/src/event/quic/ngx_event_quic.c b/src/event/quic/ngx_event_quic.c
--- a/src/event/quic/ngx_event_quic.c
+++ b/src/event/quic/ngx_event_quic.c
@@ -427,7 +427,7 @@ ngx_quic_input_handler(ngx_event_t *rev)
             return;
         }
 
-        if (!qc->closing && qc->conf->shutdown) {
+        if (!qc->closing && qc->streams.initialized && qc->conf->shutdown) {
             qc->conf->shutdown(c);
         }
 
diff --git a/src/event/quic/ngx_event_quic_streams.c b/src/event/quic/ngx_event_quic_streams.c
--- a/src/event/quic/ngx_event_quic_streams.c
+++ b/src/event/quic/ngx_event_quic_streams.c
@@ -620,6 +620,10 @@ ngx_quic_do_init_streams(ngx_connection_
         }
     }
 
+    if (ngx_exiting && qc->conf->shutdown) {
+        qc->conf->shutdown(c);
+    }
+
     for (q = ngx_queue_head(&qc->streams.uninitialized);
          q != ngx_queue_sentinel(&qc->streams.uninitialized);
          q = ngx_queue_next(q))


More information about the nginx-devel mailing list