Mercurial > hg > nginx
changeset 7773:b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Previously, PINGs and other frames extended possible keepalive time,
making it possible to keep an open HTTP/2 connection for a long time.
Now the connection is always closed as long as keepalive_timeout expires,
similarly to how it happens in HTTP/1.x.
Note that as a part of this change, incomplete frames are no longer
trigger a separate timeout, so http2_recv_timeout (replaced by
client_header_timeout in previous patches) is essentially cancelled.
The client_header_timeout is, however, used for SSL handshake and
while reading HEADERS frames.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 11 Feb 2021 21:52:24 +0300 |
parents | f790816a0e87 |
children | 827202ca1269 |
files | src/http/v2/ngx_http_v2.c |
diffstat | 1 files changed, 15 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/src/http/v2/ngx_http_v2.c Thu Feb 11 21:52:23 2021 +0300 +++ b/src/http/v2/ngx_http_v2.c Thu Feb 11 21:52:24 2021 +0300 @@ -325,6 +325,10 @@ rev->handler = ngx_http_v2_read_handler; c->write->handler = ngx_http_v2_write_handler; + if (c->read->timer_set) { + ngx_del_timer(c->read); + } + c->idle = 1; ngx_reusable_connection(c, 0); @@ -455,14 +459,6 @@ h2c->blocked = 0; - if (h2c->processing || h2c->pushing) { - if (rev->timer_set) { - ngx_del_timer(rev); - } - - return; - } - ngx_http_v2_handle_connection(h2c); } @@ -638,7 +634,6 @@ ngx_int_t rc; ngx_connection_t *c; ngx_http_core_loc_conf_t *clcf; - ngx_http_core_srv_conf_t *cscf; if (h2c->last_out || h2c->processing || h2c->pushing) { return; @@ -675,15 +670,16 @@ return; } + clcf = ngx_http_get_module_loc_conf(h2c->http_connection->conf_ctx, + ngx_http_core_module); + + if (!c->read->timer_set) { + ngx_add_timer(c->read, clcf->keepalive_timeout); + } + ngx_reusable_connection(c, 1); if (h2c->state.incomplete) { - if (!c->read->timer_set) { - cscf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx, - ngx_http_core_module); - ngx_add_timer(c->read, cscf->client_header_timeout); - } - return; } @@ -708,11 +704,6 @@ if (c->write->timer_set) { ngx_del_timer(c->write); } - - clcf = ngx_http_get_module_loc_conf(h2c->http_connection->conf_ctx, - ngx_http_core_module); - - ngx_add_timer(c->read, clcf->keepalive_timeout); } @@ -3298,6 +3289,10 @@ h2c->priority_limit += h2scf->concurrent_streams; + if (h2c->connection->read->timer_set) { + ngx_del_timer(h2c->connection->read); + } + return stream; } @@ -4709,10 +4704,6 @@ c->destroyed = 0; ngx_reusable_connection(c, 0); - if (c->read->timer_set) { - ngx_del_timer(c->read); - } - h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx, ngx_http_v2_module);