# HG changeset patch # User Roman Arutyunyan # Date 1628144432 -10800 # Node ID a9f6540e61da53b926cbcee3f78a822ac8f137c3 # Parent fe919fd63b0bb3a4dd02429fd3044df4023b560b QUIC: asynchronous shutdown. Previously, when cleaning up a QUIC stream in shutdown mode, ngx_quic_shutdown_quic() was called, which could close the QUIC connection right away. This could be a problem if the connection was referenced up the stack. For example, this could happen in ngx_quic_init_streams(), ngx_quic_close_streams(), ngx_quic_create_client_stream() etc. With a typical HTTP/3 client the issue is unlikely because of HTTP/3 uni streams which need a posted event to close. In this case QUIC connection cannot be closed right away. Now QUIC connection read event is posted and it will shut down the connection asynchronously. 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 @@ -421,7 +421,11 @@ ngx_quic_input_handler(ngx_event_t *rev) if (!rev->ready) { if (qc->closing) { ngx_quic_close_connection(c, NGX_OK); + + } else if (qc->shutdown) { + ngx_quic_shutdown_quic(c); } + return; } 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 @@ -849,7 +849,7 @@ done: (void) ngx_quic_output(pc); if (qc->shutdown) { - ngx_quic_shutdown_quic(pc); + ngx_post_event(pc->read, &ngx_posted_events); } }