From fafec1fdb875dbd314de9822311f99fac8741eb9 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 7 Aug 2013 21:27:08 +0900 Subject: [PATCH] nghttpx: Accept incoming bytes at least initial window size --- src/shrpx_http2_upstream.cc | 7 ++++++- src/shrpx_spdy_session.cc | 4 +++- src/shrpx_spdy_upstream.cc | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/shrpx_http2_upstream.cc b/src/shrpx_http2_upstream.cc index fcbe600e..dbc250b4 100644 --- a/src/shrpx_http2_upstream.cc +++ b/src/shrpx_http2_upstream.cc @@ -284,8 +284,13 @@ void on_data_chunk_recv_callback(nghttp2_session *session, } if(upstream->get_flow_control()) { downstream->inc_recv_window_size(len); + // In case that user specified initial window size is smaller + // than default one and avoid stream tear down for the first + // request due to race condition, we allow at least default + // initial window size. if(downstream->get_recv_window_size() > - upstream->get_initial_window_size()) { + std::max(NGHTTP2_INITIAL_WINDOW_SIZE, + upstream->get_initial_window_size())) { if(LOG_ENABLED(INFO)) { ULOG(INFO, upstream) << "Flow control error: recv_window_size=" << downstream->get_recv_window_size() diff --git a/src/shrpx_spdy_session.cc b/src/shrpx_spdy_session.cc index ab565777..7f8daaa2 100644 --- a/src/shrpx_spdy_session.cc +++ b/src/shrpx_spdy_session.cc @@ -906,7 +906,9 @@ void on_data_chunk_recv_callback(nghttp2_session *session, if(spdy->get_flow_control()) { sd->dconn->inc_recv_window_size(len); - if(sd->dconn->get_recv_window_size() > spdy->get_initial_window_size()) { + if(sd->dconn->get_recv_window_size() > + std::max(NGHTTP2_INITIAL_WINDOW_SIZE, + spdy->get_initial_window_size())) { if(LOG_ENABLED(INFO)) { SSLOG(INFO, spdy) << "Flow control error: recv_window_size=" << sd->dconn->get_recv_window_size() diff --git a/src/shrpx_spdy_upstream.cc b/src/shrpx_spdy_upstream.cc index 3d2b3d2d..f9059bf8 100644 --- a/src/shrpx_spdy_upstream.cc +++ b/src/shrpx_spdy_upstream.cc @@ -248,7 +248,7 @@ void on_data_chunk_recv_callback(spdylay_session *session, if(upstream->get_flow_control()) { downstream->inc_recv_window_size(len); if(downstream->get_recv_window_size() > - upstream->get_initial_window_size()) { + std::max(65536, upstream->get_initial_window_size())) { if(LOG_ENABLED(INFO)) { ULOG(INFO, upstream) << "Flow control error: recv_window_size=" << downstream->get_recv_window_size()