diff src/http/v2/ngx_http_v2.c @ 7771:02be1baed382

HTTP/2: removed http2_recv_timeout. Instead, the client_header_timeout is now used for HTTP/2 reading. Further, the timeout is changed to be set once till no further data left to read, similarly to how client_header_timeout is used in other places.
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 11 Feb 2021 21:52:20 +0300
parents 0a5687a458de
children f790816a0e87
line wrap: on
line diff
--- a/src/http/v2/ngx_http_v2.c
+++ b/src/http/v2/ngx_http_v2.c
@@ -635,9 +635,10 @@ error:
 static void
 ngx_http_v2_handle_connection(ngx_http_v2_connection_t *h2c)
 {
-    ngx_int_t                rc;
-    ngx_connection_t        *c;
-    ngx_http_v2_srv_conf_t  *h2scf;
+    ngx_int_t                  rc;
+    ngx_connection_t          *c;
+    ngx_http_v2_srv_conf_t    *h2scf;
+    ngx_http_core_srv_conf_t  *cscf;
 
     if (h2c->last_out || h2c->processing || h2c->pushing) {
         return;
@@ -676,10 +677,13 @@ ngx_http_v2_handle_connection(ngx_http_v
 
     ngx_reusable_connection(c, 1);
 
-    h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx,
-                                         ngx_http_v2_module);
     if (h2c->state.incomplete) {
-        ngx_add_timer(c->read, h2scf->recv_timeout);
+        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;
     }
 
@@ -705,6 +709,9 @@ ngx_http_v2_handle_connection(ngx_http_v
         ngx_del_timer(c->write);
     }
 
+    h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx,
+                                         ngx_http_v2_module);
+
     ngx_add_timer(c->read, h2scf->idle_timeout);
 }
 
@@ -4696,6 +4703,10 @@ 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);
+    }
+
     h2c->pool = ngx_create_pool(h2scf->pool_size, h2c->connection->log);
     if (h2c->pool == NULL) {
         ngx_http_v2_finalize_connection(h2c, NGX_HTTP_V2_INTERNAL_ERROR);