From d34095cf490fed005c48369490e49180b618e5ae Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 11 Mar 2015 21:14:55 +0900 Subject: [PATCH] nghttpx: Pin HTTP/2 upstream to one Http2Session to improve performance --- src/shrpx_client_handler.cc | 6 +++--- src/shrpx_client_handler.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/shrpx_client_handler.cc b/src/shrpx_client_handler.cc index b7f1a50c..04702200 100644 --- a/src/shrpx_client_handler.cc +++ b/src/shrpx_client_handler.cc @@ -363,6 +363,7 @@ ClientHandler::ClientHandler(Worker *worker, int fd, SSL *ssl, get_config()->write_burst, get_config()->read_rate, get_config()->read_burst, writecb, readcb, timeoutcb, this), ipaddr_(ipaddr), port_(port), worker_(worker), + http2session_(worker_->next_http2_session()), left_connhd_len_(NGHTTP2_CLIENT_CONNECTION_PREFACE_LEN), should_close_after_write_(false) { @@ -608,10 +609,9 @@ ClientHandler::get_downstream_connection() { } auto dconn_pool = worker_->get_dconn_pool(); - auto http2session = worker_->next_http2_session(); - if (http2session) { - dconn = make_unique(dconn_pool, http2session); + if (http2session_) { + dconn = make_unique(dconn_pool, http2session_); } else { dconn = make_unique(dconn_pool, conn_.loop); } diff --git a/src/shrpx_client_handler.h b/src/shrpx_client_handler.h index ac18d4e7..88d11675 100644 --- a/src/shrpx_client_handler.h +++ b/src/shrpx_client_handler.h @@ -139,6 +139,7 @@ private: std::function read_, write_; std::function on_read_, on_write_; Worker *worker_; + Http2Session *http2session_; // The number of bytes of HTTP/2 client connection header to read size_t left_connhd_len_; bool should_close_after_write_;