# HG changeset patch # User Roman Arutyunyan <a...@nginx.com> # Date 1655998736 -14400 # Thu Jun 23 19:38:56 2022 +0400 # Branch quic # Node ID 56b6cd5bc78bba1085a168c0f5ea9a03d34646c5 # Parent 1912c09e0e4d746ec0a4c2140b6d2046b283b647 HTTP/3: keepalive timer for hq mode.
diff --git a/src/http/v3/ngx_http_v3.c b/src/http/v3/ngx_http_v3.c --- a/src/http/v3/ngx_http_v3.c +++ b/src/http/v3/ngx_http_v3.c @@ -61,7 +61,7 @@ ngx_http_v3_init_session(ngx_connection_ hc->v3_session = h3c; - return ngx_http_v3_send_settings(c); + return NGX_OK; failed: diff --git a/src/http/v3/ngx_http_v3_request.c b/src/http/v3/ngx_http_v3_request.c --- a/src/http/v3/ngx_http_v3_request.c +++ b/src/http/v3/ngx_http_v3_request.c @@ -61,6 +61,7 @@ static const struct { void ngx_http_v3_init(ngx_connection_t *c) { + ngx_http_v3_session_t *h3c; ngx_http_connection_t *hc, *phc; ngx_http_v3_srv_conf_t *h3scf; ngx_http_core_loc_conf_t *clcf; @@ -87,6 +88,13 @@ ngx_http_v3_init(ngx_connection_t *c) ngx_set_connection_log(c, clcf->error_log); } + h3c = hc->v3_session; + + if (h3c == NULL && ngx_http_v3_init_session(c) != NGX_OK) { + ngx_http_close_connection(c); + return; + } + #if (NGX_HTTP_V3_HQ) if (h3scf->hq) { ngx_http_v3_init_hq_stream(c); @@ -94,7 +102,7 @@ ngx_http_v3_init(ngx_connection_t *c) } #endif - if (ngx_http_v3_init_session(c) != NGX_OK) { + if (h3c == NULL && ngx_http_v3_send_settings(c)) { ngx_http_close_connection(c); return; } @@ -115,6 +123,9 @@ ngx_http_v3_init_hq_stream(ngx_connectio { uint64_t n; ngx_event_t *rev; + ngx_connection_t *pc; + ngx_pool_cleanup_t *cln; + ngx_http_v3_session_t *h3c; ngx_http_connection_t *hc; ngx_http_core_loc_conf_t *clcf; ngx_http_core_srv_conf_t *cscf; @@ -159,6 +170,28 @@ ngx_http_v3_init_hq_stream(ngx_connectio return; } + pc = c->quic->parent; + h3c = ngx_http_v3_get_session(c); + + cln = ngx_pool_cleanup_add(c->pool, 0); + if (cln == NULL) { + ngx_quic_finalize_connection(pc, NGX_HTTP_V3_ERR_INTERNAL_ERROR, + "internal error"); + ngx_http_close_connection(c); + return; + } + + cln->handler = ngx_http_v3_cleanup_connection; + cln->data = c; + + if (h3c->nrequests++ == 0) { + ngx_reusable_connection(pc, 0); + } + + if (h3c->keepalive.timer_set) { + ngx_del_timer(&h3c->keepalive); + } + rev = c->read; if (rev->ready) { _______________________________________________ nginx-devel mailing list -- nginx-devel@nginx.org To unsubscribe send an email to nginx-devel-le...@nginx.org