diff options
| author | Roman Arutyunyan <arut@nginx.com> | 2022-10-19 17:45:18 +0400 |
|---|---|---|
| committer | Roman Arutyunyan <arut@nginx.com> | 2022-10-19 17:45:18 +0400 |
| commit | fed44881d3bf5126b49144dba58f2830e0fe9866 (patch) | |
| tree | 6137fc2bdbb276dfceb695f1f10bc674e44fa139 /src/event | |
| parent | dd4c31fc34bd8390dd3fa9e804afc15b57b69135 (diff) | |
| download | nginx-fed44881d3bf5126b49144dba58f2830e0fe9866.tar.gz nginx-fed44881d3bf5126b49144dba58f2830e0fe9866.tar.bz2 | |
QUIC: idle mode for main connection.
Now main QUIC connection for HTTP/3 always has c->idle flag set. This allows
the connection to receive worker shutdown notification. It is passed to
application level via a new conf->shutdown() callback.
The HTTP/3 shutdown callback sends GOAWAY to client and gracefully shuts down
the QUIC connection.
Diffstat (limited to 'src/event')
| -rw-r--r-- | src/event/quic/ngx_event_quic.c | 17 | ||||
| -rw-r--r-- | src/event/quic/ngx_event_quic.h | 5 |
2 files changed, 19 insertions, 3 deletions
diff --git a/src/event/quic/ngx_event_quic.c b/src/event/quic/ngx_event_quic.c index 7245ee7d0..a28f5a7ac 100644 --- a/src/event/quic/ngx_event_quic.c +++ b/src/event/quic/ngx_event_quic.c @@ -341,6 +341,7 @@ ngx_quic_new_connection(ngx_connection_t *c, ngx_quic_conf_t *conf, return NULL; } + c->idle = 1; ngx_reusable_connection(c, 1); ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, @@ -420,9 +421,19 @@ ngx_quic_input_handler(ngx_event_t *rev) } if (c->close) { - qc->error = NGX_QUIC_ERR_NO_ERROR; - qc->error_reason = "graceful shutdown"; - ngx_quic_close_connection(c, NGX_ERROR); + c->close = 0; + + if (!ngx_exiting) { + qc->error = NGX_QUIC_ERR_NO_ERROR; + qc->error_reason = "graceful shutdown"; + ngx_quic_close_connection(c, NGX_ERROR); + return; + } + + if (!qc->closing && qc->conf->shutdown) { + qc->conf->shutdown(c); + } + return; } diff --git a/src/event/quic/ngx_event_quic.h b/src/event/quic/ngx_event_quic.h index d33bd8d4d..335d925cb 100644 --- a/src/event/quic/ngx_event_quic.h +++ b/src/event/quic/ngx_event_quic.h @@ -28,6 +28,9 @@ #define NGX_QUIC_STREAM_UNIDIRECTIONAL 0x02 +typedef void (*ngx_quic_shutdown_pt)(ngx_connection_t *c); + + typedef enum { NGX_QUIC_STREAM_SEND_READY = 0, NGX_QUIC_STREAM_SEND_SEND, @@ -74,6 +77,8 @@ typedef struct { ngx_int_t stream_reject_code_uni; ngx_int_t stream_reject_code_bidi; + ngx_quic_shutdown_pt shutdown; + u_char av_token_key[NGX_QUIC_AV_KEY_LEN]; u_char sr_token_key[NGX_QUIC_SR_KEY_LEN]; } ngx_quic_conf_t; |
