aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoman Arutyunyan <arut@nginx.com>2022-10-25 12:52:09 +0400
committerRoman Arutyunyan <arut@nginx.com>2022-10-25 12:52:09 +0400
commit36f7b31f9578c0d393cfe82d4e23c76a7539f34e (patch)
tree7ff330a8a1c69bdb4bc629127f92a9f7b90ef717 /src
parent64ccdf45288c46b5f8e12426d3802c44d789d115 (diff)
downloadnginx-36f7b31f9578c0d393cfe82d4e23c76a7539f34e.tar.gz
nginx-36f7b31f9578c0d393cfe82d4e23c76a7539f34e.zip
HTTP/3: implement keepalive for hq.
Previously, keepalive timer was deleted in ngx_http_v3_wait_request_handler() and set in request cleanup handler. This worked for HTTP/3 connections, but not for hq connections. Now keepalive timer is deleted in ngx_http_v3_init_request_stream() and set in connection cleanup handler, which works both for HTTP/3 and hq.
Diffstat (limited to 'src')
-rw-r--r--src/http/v3/ngx_http_v3_request.c47
1 files changed, 30 insertions, 17 deletions
diff --git a/src/http/v3/ngx_http_v3_request.c b/src/http/v3/ngx_http_v3_request.c
index 2e7dd811d..f05198903 100644
--- a/src/http/v3/ngx_http_v3_request.c
+++ b/src/http/v3/ngx_http_v3_request.c
@@ -12,6 +12,7 @@
static void ngx_http_v3_init_request_stream(ngx_connection_t *c);
static void ngx_http_v3_wait_request_handler(ngx_event_t *rev);
+static void ngx_http_v3_cleanup_connection(void *data);
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,
@@ -165,6 +166,7 @@ ngx_http_v3_init_request_stream(ngx_connection_t *c)
uint64_t n;
ngx_event_t *rev;
ngx_connection_t *pc;
+ ngx_pool_cleanup_t *cln;
ngx_http_connection_t *hc;
ngx_http_v3_session_t *h3c;
ngx_http_core_loc_conf_t *clcf;
@@ -220,6 +222,21 @@ ngx_http_v3_init_request_stream(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_connection;
+ cln->data = c;
+
+ h3c->nrequests++;
+
+ if (h3c->keepalive.timer_set) {
+ ngx_del_timer(&h3c->keepalive);
+ }
+
rev = c->read;
#if (NGX_HTTP_V3_HQ)
@@ -256,7 +273,6 @@ ngx_http_v3_wait_request_handler(ngx_event_t *rev)
ngx_connection_t *c;
ngx_pool_cleanup_t *cln;
ngx_http_request_t *r;
- ngx_http_v3_session_t *h3c;
ngx_http_connection_t *hc;
ngx_http_core_srv_conf_t *cscf;
@@ -377,13 +393,6 @@ ngx_http_v3_wait_request_handler(ngx_event_t *rev)
cln->handler = ngx_http_v3_cleanup_request;
cln->data = r;
- h3c = ngx_http_v3_get_session(c);
- h3c->nrequests++;
-
- if (h3c->keepalive.timer_set) {
- ngx_del_timer(&h3c->keepalive);
- }
-
rev->handler = ngx_http_v3_process_request;
ngx_http_v3_process_request(rev);
}
@@ -418,20 +427,13 @@ ngx_http_v3_reset_stream(ngx_connection_t *c)
static void
-ngx_http_v3_cleanup_request(void *data)
+ngx_http_v3_cleanup_connection(void *data)
{
- ngx_http_request_t *r = data;
+ ngx_connection_t *c = data;
- ngx_connection_t *c;
ngx_http_v3_session_t *h3c;
ngx_http_core_loc_conf_t *clcf;
- c = r->connection;
-
- if (!r->response_sent) {
- c->error = 1;
- }
-
h3c = ngx_http_v3_get_session(c);
if (--h3c->nrequests == 0) {
@@ -442,6 +444,17 @@ ngx_http_v3_cleanup_request(void *data)
static void
+ngx_http_v3_cleanup_request(void *data)
+{
+ ngx_http_request_t *r = data;
+
+ if (!r->response_sent) {
+ r->connection->error = 1;
+ }
+}
+
+
+static void
ngx_http_v3_process_request(ngx_event_t *rev)
{
u_char *p;