diff options
author | Roman Arutyunyan <arut@nginx.com> | 2021-03-30 16:48:38 +0300 |
---|---|---|
committer | Roman Arutyunyan <arut@nginx.com> | 2021-03-30 16:48:38 +0300 |
commit | f4ab680bcb34d832a1dfd086e3641bf78c0a207c (patch) | |
tree | 3d860eb088a56835a7a9463f96d3f70986e0cf01 /src/http/v3/ngx_http_v3_streams.c | |
parent | 9533df5b728833dd516f44d18953a3731c29e787 (diff) | |
download | nginx-f4ab680bcb34d832a1dfd086e3641bf78c0a207c.tar.gz nginx-f4ab680bcb34d832a1dfd086e3641bf78c0a207c.zip |
HTTP/3: keepalive timeout.
This timeout limits the time when no client request streams exist.
Diffstat (limited to 'src/http/v3/ngx_http_v3_streams.c')
-rw-r--r-- | src/http/v3/ngx_http_v3_streams.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/http/v3/ngx_http_v3_streams.c b/src/http/v3/ngx_http_v3_streams.c index eac49a659..f2036982f 100644 --- a/src/http/v3/ngx_http_v3_streams.c +++ b/src/http/v3/ngx_http_v3_streams.c @@ -29,6 +29,8 @@ typedef struct { } ngx_http_v3_push_t; +static void ngx_http_v3_keepalive_handler(ngx_event_t *ev); +static void ngx_http_v3_cleanup_session(void *data); static void ngx_http_v3_close_uni_stream(ngx_connection_t *c); static void ngx_http_v3_read_uni_stream_type(ngx_event_t *rev); static void ngx_http_v3_uni_read_handler(ngx_event_t *rev); @@ -43,6 +45,7 @@ ngx_int_t ngx_http_v3_init_session(ngx_connection_t *c) { ngx_connection_t *pc; + ngx_pool_cleanup_t *cln; ngx_http_connection_t *phc; ngx_http_v3_connection_t *h3c; @@ -67,12 +70,50 @@ ngx_http_v3_init_session(ngx_connection_t *c) ngx_queue_init(&h3c->blocked); ngx_queue_init(&h3c->pushing); + h3c->keepalive.log = pc->log; + h3c->keepalive.data = pc; + h3c->keepalive.handler = ngx_http_v3_keepalive_handler; + h3c->keepalive.cancelable = 1; + + cln = ngx_pool_cleanup_add(pc->pool, 0); + if (cln == NULL) { + return NGX_ERROR; + } + + cln->handler = ngx_http_v3_cleanup_session; + cln->data = h3c; + pc->data = h3c; return ngx_http_v3_send_settings(c); } +static void +ngx_http_v3_keepalive_handler(ngx_event_t *ev) +{ + ngx_connection_t *c; + + c = ev->data; + + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 keepalive handler"); + + ngx_quic_finalize_connection(c, NGX_HTTP_V3_ERR_NO_ERROR, + "keepalive timeout"); +} + + +static void +ngx_http_v3_cleanup_session(void *data) +{ + ngx_http_v3_connection_t *h3c = data; + + if (h3c->keepalive.timer_set) { + ngx_del_timer(&h3c->keepalive); + } +} + + void ngx_http_v3_init_uni_stream(ngx_connection_t *c) { |