[nginx] HTTP/2: send the output queue after emitting WINDOW_UPDATE.

Valentin Bartenev vbart at nginx.com
Tue Apr 19 14:40:01 UTC 2016


details:   http://hg.nginx.org/nginx/rev/9070ba416284
branches:  
changeset: 6520:9070ba416284
user:      Valentin Bartenev <vbart at nginx.com>
date:      Tue Apr 19 17:38:49 2016 +0300
description:
HTTP/2: send the output queue after emitting WINDOW_UPDATE.

The WINDOW_UPDATE frame could be left in the output queue for an indefinite
period of time resulting in the request timeout.

This might happen if reading of the body was triggered by an event unrelated
to client connection, e.g. by the limit_req timer.

diffstat:

 src/http/v2/ngx_http_v2.c |  10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diffs (27 lines):

diff -r 9ac934dd5dd8 -r 9070ba416284 src/http/v2/ngx_http_v2.c
--- a/src/http/v2/ngx_http_v2.c	Tue Apr 19 17:38:49 2016 +0300
+++ b/src/http/v2/ngx_http_v2.c	Tue Apr 19 17:38:49 2016 +0300
@@ -3414,6 +3414,7 @@ ngx_http_v2_read_request_body(ngx_http_r
     ngx_http_v2_stream_t      *stream;
     ngx_http_request_body_t   *rb;
     ngx_http_core_loc_conf_t  *clcf;
+    ngx_http_v2_connection_t  *h2c;
 
     stream = r->stream;
 
@@ -3498,6 +3499,15 @@ ngx_http_v2_read_request_body(ngx_http_r
             stream->skip_data = 1;
             return NGX_HTTP_INTERNAL_SERVER_ERROR;
         }
+
+        h2c = stream->connection;
+
+        if (!h2c->blocked) {
+            if (ngx_http_v2_send_output_queue(h2c) == NGX_ERROR) {
+                stream->skip_data = 1;
+                return NGX_HTTP_INTERNAL_SERVER_ERROR;
+            }
+        }
     }
 
     ngx_add_timer(r->connection->read, clcf->client_body_timeout);



More information about the nginx-devel mailing list