[nginx] HTTP/2: avoid sending output queue if there's nothing to send.

Valentin Bartenev vbart at nginx.com
Tue Jul 19 17:37:17 UTC 2016


details:   http://hg.nginx.org/nginx/rev/82efcedb310b
branches:  
changeset: 6639:82efcedb310b
user:      Valentin Bartenev <vbart at nginx.com>
date:      Tue Jul 19 20:30:21 2016 +0300
description:
HTTP/2: avoid sending output queue if there's nothing to send.

Particularly this fixes alerts on OS X and NetBSD systems when HTTP/2 is
configured over plain TCP sockets.

On these systems calling writev() with no data leads to EINVAL errors
being logged as "writev() failed (22: Invalid argument) while processing
HTTP/2 connection".

diffstat:

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

diffs (20 lines):

diff -r a2b310a8b2af -r 82efcedb310b src/http/v2/ngx_http_v2.c
--- a/src/http/v2/ngx_http_v2.c	Tue Jul 19 20:22:44 2016 +0300
+++ b/src/http/v2/ngx_http_v2.c	Tue Jul 19 20:30:21 2016 +0300
@@ -410,6 +410,16 @@ ngx_http_v2_write_handler(ngx_event_t *w
 
     ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http2 write handler");
 
+    if (h2c->last_out == NULL && !c->buffered) {
+
+        if (wev->timer_set) {
+            ngx_del_timer(wev);
+        }
+
+        ngx_http_v2_handle_connection(h2c);
+        return;
+    }
+
     h2c->blocked = 1;
 
     rc = ngx_http_v2_send_output_queue(h2c);



More information about the nginx-devel mailing list