Welcome! Log In Create A New Profile

Advanced

[nginx] HTTP/2: keepalive_timeout now armed once between requests.

Maxim Dounin
February 11, 2021 02:58PM
details: https://hg.nginx.org/nginx/rev/b64f553b1291
branches:
changeset: 7773:b64f553b1291
user: Maxim Dounin <mdounin@mdounin.ru>
date: Thu Feb 11 21:52:24 2021 +0300
description:
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.

diffstat:

src/http/v2/ngx_http_v2.c | 39 +++++++++++++++------------------------
1 files changed, 15 insertions(+), 24 deletions(-)

diffs (94 lines):

diff -r f790816a0e87 -r b64f553b1291 src/http/v2/ngx_http_v2.c
--- 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 @@ ngx_http_v2_init(ngx_event_t *rev)
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 @@ ngx_http_v2_read_handler(ngx_event_t *re

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_http_v2_handle_connection(ngx_http_v
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 @@ ngx_http_v2_handle_connection(ngx_http_v
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 @@ ngx_http_v2_handle_connection(ngx_http_v
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 @@ ngx_http_v2_create_stream(ngx_http_v2_co

h2c->priority_limit += h2scf->concurrent_streams;

+ if (h2c->connection->read->timer_set) {
+ ngx_del_timer(h2c->connection->read);
+ }
+
return stream;
}

@@ -4709,10 +4704,6 @@ ngx_http_v2_idle_handler(ngx_event_t *re
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);

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] HTTP/2: keepalive_timeout now armed once between requests.

Maxim Dounin 259 February 11, 2021 02:58PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 307
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready