]> git.kaiwu.me - nginx.git/commitdiff
HTTP/2: introduced separate handler to retry stream close.
authorMaxim Dounin <mdounin@mdounin.ru>
Mon, 23 Dec 2019 18:25:21 +0000 (21:25 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Mon, 23 Dec 2019 18:25:21 +0000 (21:25 +0300)
When ngx_http_v2_close_stream_handler() is used to retry stream close
after queued frames are sent, client timeouts on the stream can be
logged multiple times and/or in addition to already happened errors.
To resolve this, separate ngx_http_v2_retry_close_stream_handler()
was introduced, which does not try to log timeouts.

src/http/v2/ngx_http_v2.c

index d28b8090a9323269a74f08e22d2af9a5135667e4..9b5a0cd5ee31b77a1ee6f16777b58dbb520165cc 100644 (file)
@@ -178,6 +178,7 @@ static void ngx_http_v2_read_client_request_body_handler(ngx_http_request_t *r);
 static ngx_int_t ngx_http_v2_terminate_stream(ngx_http_v2_connection_t *h2c,
     ngx_http_v2_stream_t *stream, ngx_uint_t status);
 static void ngx_http_v2_close_stream_handler(ngx_event_t *ev);
+static void ngx_http_v2_retry_close_stream_handler(ngx_event_t *ev);
 static void ngx_http_v2_handle_connection_handler(ngx_event_t *rev);
 static void ngx_http_v2_idle_handler(ngx_event_t *rev);
 static void ngx_http_v2_finalize_connection(ngx_http_v2_connection_t *h2c,
@@ -4289,8 +4290,8 @@ ngx_http_v2_close_stream(ngx_http_v2_stream_t *stream, ngx_int_t rc)
 
     if (stream->queued) {
         fc->error = 1;
-        fc->write->handler = ngx_http_v2_close_stream_handler;
-        fc->read->handler = ngx_http_v2_close_stream_handler;
+        fc->write->handler = ngx_http_v2_retry_close_stream_handler;
+        fc->read->handler = ngx_http_v2_retry_close_stream_handler;
         return;
     }
 
@@ -4412,6 +4413,22 @@ ngx_http_v2_close_stream_handler(ngx_event_t *ev)
 }
 
 
+static void
+ngx_http_v2_retry_close_stream_handler(ngx_event_t *ev)
+{
+    ngx_connection_t    *fc;
+    ngx_http_request_t  *r;
+
+    fc = ev->data;
+    r = fc->data;
+
+    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, fc->log, 0,
+                   "http2 retry close stream handler");
+
+    ngx_http_v2_close_stream(r->stream, 0);
+}
+
+
 static void
 ngx_http_v2_handle_connection_handler(ngx_event_t *rev)
 {