From e4dc6cf43254d0f1e43db1189ea21b33af9fd4b9 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 29 May 2016 23:34:38 +0900 Subject: [PATCH] src: Use nghttp2_session_set_local_window_size() --- src/HttpServer.cc | 5 ++--- src/asio_client_session_impl.cc | 5 ++--- src/h2load_http2_session.cc | 11 ++++------- src/nghttp.cc | 6 +++--- src/shrpx_http2_session.cc | 10 +++++----- src/shrpx_http2_upstream.cc | 8 ++++---- 6 files changed, 20 insertions(+), 25 deletions(-) diff --git a/src/HttpServer.cc b/src/HttpServer.cc index 5070a26b..4f515e54 100644 --- a/src/HttpServer.cc +++ b/src/HttpServer.cc @@ -856,10 +856,9 @@ int Http2Handler::connection_made() { } if (config->connection_window_bits != -1) { - r = nghttp2_submit_window_update( + r = nghttp2_session_set_local_window_size( session_, NGHTTP2_FLAG_NONE, 0, - (1 << config->connection_window_bits) - 1 - - NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE); + (1 << config->connection_window_bits) - 1); if (r != 0) { return r; } diff --git a/src/asio_client_session_impl.cc b/src/asio_client_session_impl.cc index fade97bd..fafb26b1 100644 --- a/src/asio_client_session_impl.cc +++ b/src/asio_client_session_impl.cc @@ -373,9 +373,8 @@ bool session_impl::setup_session() { {NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE, window_size}}}; nghttp2_submit_settings(session_, NGHTTP2_FLAG_NONE, iv.data(), iv.size()); // increase connection window size up to window_size - nghttp2_submit_window_update(session_, NGHTTP2_FLAG_NONE, 0, - window_size - - NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE); + nghttp2_session_set_local_window_size(session_, NGHTTP2_FLAG_NONE, 0, + window_size); return true; } diff --git a/src/h2load_http2_session.cc b/src/h2load_http2_session.cc index ea71d66a..5e333964 100644 --- a/src/h2load_http2_session.cc +++ b/src/h2load_http2_session.cc @@ -219,13 +219,10 @@ void Http2Session::on_connect() { assert(rv == 0); - auto extra_connection_window = - (1 << client_->worker->config->connection_window_bits) - 1 - - NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE; - if (extra_connection_window != 0) { - nghttp2_submit_window_update(session_, NGHTTP2_FLAG_NONE, 0, - extra_connection_window); - } + auto connection_window = + (1 << client_->worker->config->connection_window_bits) - 1; + nghttp2_session_set_local_window_size(session_, NGHTTP2_FLAG_NONE, 0, + connection_window); client_->signal_write(); } diff --git a/src/nghttp.cc b/src/nghttp.cc index 2c427947..c78c10bf 100644 --- a/src/nghttp.cc +++ b/src/nghttp.cc @@ -1151,9 +1151,9 @@ int HttpClient::connection_made() { ev_timer_again(loop, &settings_timer); if (config.connection_window_bits != -1) { - int32_t wininc = (1 << config.connection_window_bits) - 1 - - NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE; - rv = nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 0, wininc); + int32_t window_size = (1 << config.connection_window_bits) - 1; + rv = nghttp2_session_set_local_window_size(session, NGHTTP2_FLAG_NONE, 0, + window_size); if (rv != 0) { return -1; } diff --git a/src/shrpx_http2_session.cc b/src/shrpx_http2_session.cc index a0361be9..bba56fa3 100644 --- a/src/shrpx_http2_session.cc +++ b/src/shrpx_http2_session.cc @@ -1533,11 +1533,11 @@ int Http2Session::connection_made() { return -1; } - auto connection_window_bits = http2conf.downstream.connection_window_bits; - if (connection_window_bits > 16) { - int32_t delta = (1 << connection_window_bits) - 1 - - NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE; - rv = nghttp2_submit_window_update(session_, NGHTTP2_FLAG_NONE, 0, delta); + if (http2conf.downstream.connection_window_bits != 16) { + int32_t window_size = + (1 << http2conf.downstream.connection_window_bits) - 1; + rv = nghttp2_session_set_local_window_size(session_, NGHTTP2_FLAG_NONE, 0, + window_size); if (rv != 0) { return -1; } diff --git a/src/shrpx_http2_upstream.cc b/src/shrpx_http2_upstream.cc index f603bd04..6c8cc6f8 100644 --- a/src/shrpx_http2_upstream.cc +++ b/src/shrpx_http2_upstream.cc @@ -883,10 +883,10 @@ Http2Upstream::Http2Upstream(ClientHandler *handler) << nghttp2_strerror(rv); } - if (http2conf.upstream.connection_window_bits > 16) { - int32_t delta = (1 << http2conf.upstream.connection_window_bits) - 1 - - NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE; - rv = nghttp2_submit_window_update(session_, NGHTTP2_FLAG_NONE, 0, delta); + if (http2conf.upstream.connection_window_bits != 16) { + int32_t window_size = (1 << http2conf.upstream.connection_window_bits) - 1; + rv = nghttp2_session_set_local_window_size(session_, NGHTTP2_FLAG_NONE, 0, + window_size); if (rv != 0) { ULOG(ERROR, this) << "nghttp2_submit_window_update() returned error: "