aboutsummaryrefslogtreecommitdiff
path: root/src/http/v3/ngx_http_v3_request.c
diff options
context:
space:
mode:
authorRoman Arutyunyan <arut@nginx.com>2021-03-30 16:48:38 +0300
committerRoman Arutyunyan <arut@nginx.com>2021-03-30 16:48:38 +0300
commitf4ab680bcb34d832a1dfd086e3641bf78c0a207c (patch)
tree3d860eb088a56835a7a9463f96d3f70986e0cf01 /src/http/v3/ngx_http_v3_request.c
parent9533df5b728833dd516f44d18953a3731c29e787 (diff)
downloadnginx-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_request.c')
-rw-r--r--src/http/v3/ngx_http_v3_request.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/http/v3/ngx_http_v3_request.c b/src/http/v3/ngx_http_v3_request.c
index d4a5faccf..b997c29a1 100644
--- a/src/http/v3/ngx_http_v3_request.c
+++ b/src/http/v3/ngx_http_v3_request.c
@@ -10,6 +10,7 @@
#include <ngx_http.h>
+static void ngx_http_v3_cleanup_request(void *data);
static void ngx_http_v3_process_request(ngx_event_t *rev);
static ngx_int_t ngx_http_v3_process_header(ngx_http_request_t *r,
ngx_str_t *name, ngx_str_t *value);
@@ -55,8 +56,10 @@ ngx_http_v3_init(ngx_connection_t *c)
uint64_t n;
ngx_buf_t *b;
ngx_event_t *rev;
+ ngx_pool_cleanup_t *cln;
ngx_http_request_t *r;
ngx_http_connection_t *hc;
+ ngx_http_v3_connection_t *h3c;
ngx_http_core_loc_conf_t *clcf;
ngx_http_core_srv_conf_t *cscf;
@@ -98,6 +101,22 @@ ngx_http_v3_init(ngx_connection_t *c)
"reached maximum number of requests");
}
+ cln = ngx_pool_cleanup_add(c->pool, 0);
+ if (cln == NULL) {
+ ngx_http_close_connection(c);
+ return;
+ }
+
+ cln->handler = ngx_http_v3_cleanup_request;
+ cln->data = c;
+
+ h3c = c->quic->parent->data;
+ h3c->nrequests++;
+
+ if (h3c->keepalive.timer_set) {
+ ngx_del_timer(&h3c->keepalive);
+ }
+
cscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_core_module);
size = cscf->client_header_buffer_size;
@@ -155,6 +174,23 @@ ngx_http_v3_init(ngx_connection_t *c)
static void
+ngx_http_v3_cleanup_request(void *data)
+{
+ ngx_connection_t *c = data;
+
+ ngx_http_core_loc_conf_t *clcf;
+ ngx_http_v3_connection_t *h3c;
+
+ h3c = c->quic->parent->data;
+
+ if (--h3c->nrequests == 0) {
+ clcf = ngx_http_v3_get_module_loc_conf(c, ngx_http_core_module);
+ ngx_add_timer(&h3c->keepalive, clcf->keepalive_timeout);
+ }
+}
+
+
+static void
ngx_http_v3_process_request(ngx_event_t *rev)
{
ssize_t n;