From 51c4f4f5b0a5c3d8ef4338299337d90b53ce6e58 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 26 Jul 2012 23:18:37 +0900 Subject: [PATCH] shrpx: Added --frontend-spdy-window-bits option --- examples/shrpx.cc | 23 +++++++++++++++++++++++ examples/shrpx_config.cc | 3 ++- examples/shrpx_config.h | 1 + examples/shrpx_spdy_upstream.cc | 2 +- 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/examples/shrpx.cc b/examples/shrpx.cc index c3c3d403..5cb8b053 100644 --- a/examples/shrpx.cc +++ b/examples/shrpx.cc @@ -265,6 +265,10 @@ void fill_default_config() // Timeout for pooled (idle) connections mod_config()->downstream_idle_read_timeout.tv_sec = 60; + // window bits for SPDY upstream connection + // 2**16 = 64KiB, which is SPDY/3 default. + mod_config()->spdy_upstream_window_bits = 16; + mod_config()->downstream_host = "localhost"; mod_config()->downstream_port = 80; @@ -378,6 +382,11 @@ void print_help(std::ostream& out) << " connection. Default: " << get_config()->downstream_idle_read_timeout.tv_sec << "\n" << " --accesslog Print simple accesslog to stderr.\n" + << " --frontend-spdy-window-bits=\n" + << " Sets the initial window size of SPDY\n" + << " frontend connection to 2**.\n" + << " Default: " + << get_config()->spdy_upstream_window_bits << "\n" << " -h, --help Print this help.\n" << std::endl; } @@ -412,6 +421,7 @@ int main(int argc, char **argv) {"backend-write-timeout", required_argument, &flag, 6 }, {"accesslog", no_argument, &flag, 7 }, {"backend-keep-alive-timeout", required_argument, &flag, 8 }, + {"frontend-spdy-window-bits", required_argument, &flag, 9 }, {"help", no_argument, 0, 'h' }, {0, 0, 0, 0 } }; @@ -508,6 +518,19 @@ int main(int argc, char **argv) mod_config()->downstream_idle_read_timeout = tv; break; } + case 9: { + // --frontend-spdy-window-bits + errno = 0; + unsigned long int n = strtoul(optarg, 0, 10); + if(errno == 0 && n < 31) { + mod_config()->spdy_upstream_window_bits = n; + } else { + std::cerr << "-w: specify the integer in the range [0, 30], inclusive" + << std::endl; + exit(EXIT_FAILURE); + } + break; + } default: break; } diff --git a/examples/shrpx_config.cc b/examples/shrpx_config.cc index 8f6c6dc0..562d5b67 100644 --- a/examples/shrpx_config.cc +++ b/examples/shrpx_config.cc @@ -43,7 +43,8 @@ Config::Config() spdy_max_concurrent_streams(0), spdy_proxy(false), add_x_forwarded_for(false), - accesslog(false) + accesslog(false), + spdy_upstream_window_bits(0) {} namespace { diff --git a/examples/shrpx_config.h b/examples/shrpx_config.h index b44ea0cd..fc33fe0a 100644 --- a/examples/shrpx_config.h +++ b/examples/shrpx_config.h @@ -69,6 +69,7 @@ struct Config { bool spdy_proxy; bool add_x_forwarded_for; bool accesslog; + size_t spdy_upstream_window_bits; Config(); }; diff --git a/examples/shrpx_spdy_upstream.cc b/examples/shrpx_spdy_upstream.cc index c2cabc64..617d70aa 100644 --- a/examples/shrpx_spdy_upstream.cc +++ b/examples/shrpx_spdy_upstream.cc @@ -297,7 +297,7 @@ SpdyUpstream::SpdyUpstream(uint16_t version, ClientHandler *handler) if(version == SPDYLAY_PROTO_SPDY3) { int val = 1; flow_control_ = true; - initial_window_size_ = 64*1024; // specified by SPDY/3 spec. + initial_window_size_ = 1 << get_config()->spdy_upstream_window_bits; rv = spdylay_session_set_option(session_, SPDYLAY_OPT_NO_AUTO_WINDOW_UPDATE, &val, sizeof(val));