[nginx] HTTP/2: removed http2_recv_timeout.

Maxim Dounin mdounin at mdounin.ru
Thu Feb 11 19:57:33 UTC 2021


details:   https://hg.nginx.org/nginx/rev/02be1baed382
branches:  
changeset: 7771:02be1baed382
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Thu Feb 11 21:52:20 2021 +0300
description:
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.

diffstat:

 src/http/v2/ngx_http_v2.c        |  23 +++++++++++++++++------
 src/http/v2/ngx_http_v2_module.c |  32 +++++++++++++++++++++++++-------
 src/http/v2/ngx_http_v2_module.h |   1 -
 3 files changed, 42 insertions(+), 14 deletions(-)

diffs (133 lines):

diff -r de0b6f1fe4e4 -r 02be1baed382 src/http/v2/ngx_http_v2.c
--- a/src/http/v2/ngx_http_v2.c	Thu Feb 11 21:52:19 2021 +0300
+++ b/src/http/v2/ngx_http_v2.c	Thu Feb 11 21:52:20 2021 +0300
@@ -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);
diff -r de0b6f1fe4e4 -r 02be1baed382 src/http/v2/ngx_http_v2_module.c
--- a/src/http/v2/ngx_http_v2_module.c	Thu Feb 11 21:52:19 2021 +0300
+++ b/src/http/v2/ngx_http_v2_module.c	Thu Feb 11 21:52:20 2021 +0300
@@ -36,6 +36,13 @@ static char *ngx_http_v2_preread_size(ng
 static char *ngx_http_v2_streams_index_mask(ngx_conf_t *cf, void *post,
     void *data);
 static char *ngx_http_v2_chunk_size(ngx_conf_t *cf, void *post, void *data);
+static char *ngx_http_v2_obsolete(ngx_conf_t *cf, ngx_command_t *cmd,
+    void *conf);
+
+
+static ngx_conf_deprecated_t  ngx_http_v2_recv_timeout_deprecated = {
+    ngx_conf_deprecated, "http2_recv_timeout", "client_header_timeout"
+};
 
 
 static ngx_conf_post_t  ngx_http_v2_recv_buffer_size_post =
@@ -117,10 +124,10 @@ static ngx_command_t  ngx_http_v2_comman
 
     { ngx_string("http2_recv_timeout"),
       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
-      ngx_conf_set_msec_slot,
-      NGX_HTTP_SRV_CONF_OFFSET,
-      offsetof(ngx_http_v2_srv_conf_t, recv_timeout),
-      NULL },
+      ngx_http_v2_obsolete,
+      0,
+      0,
+      &ngx_http_v2_recv_timeout_deprecated },
 
     { ngx_string("http2_idle_timeout"),
       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
@@ -304,7 +311,6 @@ ngx_http_v2_create_srv_conf(ngx_conf_t *
 
     h2scf->streams_index_mask = NGX_CONF_UNSET_UINT;
 
-    h2scf->recv_timeout = NGX_CONF_UNSET_MSEC;
     h2scf->idle_timeout = NGX_CONF_UNSET_MSEC;
 
     return h2scf;
@@ -335,8 +341,6 @@ ngx_http_v2_merge_srv_conf(ngx_conf_t *c
     ngx_conf_merge_uint_value(conf->streams_index_mask,
                               prev->streams_index_mask, 32 - 1);
 
-    ngx_conf_merge_msec_value(conf->recv_timeout,
-                              prev->recv_timeout, 30000);
     ngx_conf_merge_msec_value(conf->idle_timeout,
                               prev->idle_timeout, 180000);
 
@@ -539,3 +543,17 @@ ngx_http_v2_chunk_size(ngx_conf_t *cf, v
 
     return NGX_CONF_OK;
 }
+
+
+static char *
+ngx_http_v2_obsolete(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+{
+    ngx_conf_deprecated_t  *d = cmd->post;
+
+    ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
+                       "the \"%s\" directive is obsolete, "
+                       "use the \"%s\" directive instead",
+                       d->old_name, d->new_name);
+
+    return NGX_CONF_OK;
+}
diff -r de0b6f1fe4e4 -r 02be1baed382 src/http/v2/ngx_http_v2_module.h
--- a/src/http/v2/ngx_http_v2_module.h	Thu Feb 11 21:52:19 2021 +0300
+++ b/src/http/v2/ngx_http_v2_module.h	Thu Feb 11 21:52:20 2021 +0300
@@ -29,7 +29,6 @@ typedef struct {
     size_t                          max_header_size;
     size_t                          preread_size;
     ngx_uint_t                      streams_index_mask;
-    ngx_msec_t                      recv_timeout;
     ngx_msec_t                      idle_timeout;
 } ngx_http_v2_srv_conf_t;
 


More information about the nginx-devel mailing list