From 03bd29044e8367b9e44ac7b31e0c7aa152cf6b60 Mon Sep 17 00:00:00 2001 From: Edward Wang Date: Wed, 19 Jun 2024 13:48:59 -0700 Subject: Always respect_keepalive when releasing http session MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a user calls `release_http_session` on an http Connector, it is usually implied that they intend to reuse the underlying connection if possible. Previously for H1 this involved reaching into the H1 client Session and calling `respect_keepalive`. The new behavior always respects keepalive as part of releasing the http session, as it was very easy to overlook this step and unintentionally disable connection reuse for H1 sessions. --- .bleep | 2 +- pingora-core/src/connectors/http/v1.rs | 3 ++- pingora-proxy/src/proxy_h1.rs | 5 +---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.bleep b/.bleep index dd860b4..990b361 100644 --- a/.bleep +++ b/.bleep @@ -1 +1 @@ -19506db280fe5f52641e5c1ffd48e4b62f536f18 \ No newline at end of file +b8ac54b482f643f04533dcc04061b1575482c92d \ No newline at end of file diff --git a/pingora-core/src/connectors/http/v1.rs b/pingora-core/src/connectors/http/v1.rs index 7958a09..66f7bbb 100644 --- a/pingora-core/src/connectors/http/v1.rs +++ b/pingora-core/src/connectors/http/v1.rs @@ -51,10 +51,11 @@ impl Connector { pub async fn release_http_session( &self, - session: HttpSession, + mut session: HttpSession, peer: &P, idle_timeout: Option, ) { + session.respect_keepalive(); if let Some(stream) = session.reuse().await { self.transport .release_stream(stream, peer.reuse_hash(), idle_timeout); diff --git a/pingora-proxy/src/proxy_h1.rs b/pingora-proxy/src/proxy_h1.rs index feac860..de49c03 100644 --- a/pingora-proxy/src/proxy_h1.rs +++ b/pingora-proxy/src/proxy_h1.rs @@ -98,10 +98,7 @@ impl HttpProxy { ); match ret { - Ok((_first, _second)) => { - client_session.respect_keepalive(); - (true, true, None) - } + Ok((_first, _second)) => (true, true, None), Err(e) => (false, false, Some(e)), } } -- cgit v1.2.3