src: Make window size - 1

To match the -w16 to 65535, which is HTTP/2.0 default initial window
size, decrement 1 from (1 << window_bits).
This commit is contained in:
Tatsuhiro Tsujikawa 2013-08-03 19:53:07 +09:00
parent 9823b12718
commit f613f68a13
5 changed files with 10 additions and 9 deletions

View File

@ -330,7 +330,7 @@ size_t populate_settings(nghttp2_settings_entry *iv)
iv[0].value = 100; iv[0].value = 100;
iv[1].settings_id = NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE; iv[1].settings_id = NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE;
if(config.window_bits != -1) { if(config.window_bits != -1) {
iv[1].value = 1 << config.window_bits; iv[1].value = (1 << config.window_bits) - 1;
} else { } else {
iv[1].value = NGHTTP2_INITIAL_WINDOW_SIZE; iv[1].value = NGHTTP2_INITIAL_WINDOW_SIZE;
} }
@ -1423,7 +1423,7 @@ void print_help(std::ostream& out)
<< " filename. Not implemented yet.\n" << " filename. Not implemented yet.\n"
<< " -t, --timeout=<N> Timeout each request after <N> seconds.\n" << " -t, --timeout=<N> Timeout each request after <N> seconds.\n"
<< " -w, --window-bits=<N>\n" << " -w, --window-bits=<N>\n"
<< " Sets the initial window size to 2**<N>.\n" << " Sets the initial window size to 2**<N>-1.\n"
<< " -a, --get-assets Download assets such as stylesheets, images\n" << " -a, --get-assets Download assets such as stylesheets, images\n"
<< " and script files linked from the downloaded\n" << " and script files linked from the downloaded\n"
<< " resource. Only links whose origins are the\n" << " resource. Only links whose origins are the\n"

View File

@ -351,8 +351,9 @@ void fill_default_config()
// Timeout for pooled (idle) connections // Timeout for pooled (idle) connections
mod_config()->downstream_idle_read_timeout.tv_sec = 60; mod_config()->downstream_idle_read_timeout.tv_sec = 60;
// window bits for SPDY upstream/downstream connection. 2**16 = // window bits for HTTP/2.0 and SPDY upstream/downstream
// 64KiB, which is SPDY/3 default. // connection. 2**16-1 = 64KiB-1, which is HTTP/2.0 default. Please
// note that SPDY/3 default is 64KiB.
mod_config()->spdy_upstream_window_bits = 16; mod_config()->spdy_upstream_window_bits = 16;
mod_config()->spdy_downstream_window_bits = 16; mod_config()->spdy_downstream_window_bits = 16;
@ -533,13 +534,13 @@ void print_help(std::ostream& out)
<< get_config()->spdy_max_concurrent_streams << "\n" << get_config()->spdy_max_concurrent_streams << "\n"
<< " --frontend-spdy-window-bits=<N>\n" << " --frontend-spdy-window-bits=<N>\n"
<< " Sets the initial window size of HTTP/2.0 and SPDY\n" << " Sets the initial window size of HTTP/2.0 and SPDY\n"
<< " frontend connection to 2**<N>.\n" << " frontend connection to 2**<N>-1.\n"
<< " Default: " << " Default: "
<< get_config()->spdy_upstream_window_bits << "\n" << get_config()->spdy_upstream_window_bits << "\n"
<< " --frontend-no-tls Disable SSL/TLS on frontend connections.\n" << " --frontend-no-tls Disable SSL/TLS on frontend connections.\n"
<< " --backend-spdy-window-bits=<N>\n" << " --backend-spdy-window-bits=<N>\n"
<< " Sets the initial window size of HTTP/2.0 and SPDY\n" << " Sets the initial window size of HTTP/2.0 and SPDY\n"
<< " backend connection to 2**<N>.\n" << " backend connection to 2**<N>-1.\n"
<< " Default: " << " Default: "
<< get_config()->spdy_downstream_window_bits << "\n" << get_config()->spdy_downstream_window_bits << "\n"
<< " --backend-no-tls Disable SSL/TLS on backend connections.\n" << " --backend-no-tls Disable SSL/TLS on backend connections.\n"

View File

@ -396,7 +396,7 @@ Http2Upstream::Http2Upstream(ClientHandler *handler)
int val = 1; int val = 1;
flow_control_ = true; flow_control_ = true;
initial_window_size_ = 1 << get_config()->spdy_upstream_window_bits; initial_window_size_ = (1 << get_config()->spdy_upstream_window_bits) - 1;
rv = nghttp2_session_set_option(session_, rv = nghttp2_session_set_option(session_,
NGHTTP2_OPT_NO_AUTO_WINDOW_UPDATE, &val, NGHTTP2_OPT_NO_AUTO_WINDOW_UPDATE, &val,
sizeof(val)); sizeof(val));

View File

@ -597,7 +597,7 @@ int SpdySession::submit_window_update(SpdyDownstreamConnection *dconn,
int32_t SpdySession::get_initial_window_size() const int32_t SpdySession::get_initial_window_size() const
{ {
return 1 << get_config()->spdy_downstream_window_bits; return (1 << get_config()->spdy_downstream_window_bits) - 1;
} }
bool SpdySession::get_flow_control() const bool SpdySession::get_flow_control() const

View File

@ -361,7 +361,7 @@ SpdyUpstream::SpdyUpstream(uint16_t version, ClientHandler *handler)
if(version == SPDYLAY_PROTO_SPDY3) { if(version == SPDYLAY_PROTO_SPDY3) {
int val = 1; int val = 1;
flow_control_ = true; flow_control_ = true;
initial_window_size_ = 1 << get_config()->spdy_upstream_window_bits; initial_window_size_ = (1 << get_config()->spdy_upstream_window_bits) - 1;
rv = spdylay_session_set_option(session_, rv = spdylay_session_set_option(session_,
SPDYLAY_OPT_NO_AUTO_WINDOW_UPDATE, &val, SPDYLAY_OPT_NO_AUTO_WINDOW_UPDATE, &val,
sizeof(val)); sizeof(val));