From 7419b1967e7686b00aefb7bcd2a4dfe59b31e639 Mon Sep 17 00:00:00 2001 From: Yuchen Wu Date: Tue, 8 Oct 2024 13:45:53 -0700 Subject: Check the current advertised h2 max streams MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change fixes an issue that the actual current max send streams is ignored. This change requires h2 >= 0.4.6 --- .bleep | 2 +- Cargo.toml | 2 +- pingora-core/src/connectors/http/v2.rs | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.bleep b/.bleep index c142fa0..045b30f 100644 --- a/.bleep +++ b/.bleep @@ -1 +1 @@ -4b2957a626c93fec5e24438cbbc0b506bbca25a6 \ No newline at end of file +ba954539761beee5e5d09b66c3a2957212aa499f diff --git a/Cargo.toml b/Cargo.toml index f50a2f5..1ec85f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ httparse = "1" bytes = "1.0" http = "1.0.0" log = "0.4" -h2 = ">=0.4.4" +h2 = ">=0.4.6" once_cell = "1" lru = "0" ahash = ">=0.8.9" diff --git a/pingora-core/src/connectors/http/v2.rs b/pingora-core/src/connectors/http/v2.rs index a1f295a..ad41f6b 100644 --- a/pingora-core/src/connectors/http/v2.rs +++ b/pingora-core/src/connectors/http/v2.rs @@ -85,9 +85,12 @@ impl ConnectionRef { release_lock: Arc::new(Mutex::new(())), })) } + pub fn more_streams_allowed(&self) -> bool { + let current = self.0.current_streams.load(Ordering::Relaxed); !self.is_shutting_down() - && self.0.max_streams > self.0.current_streams.load(Ordering::Relaxed) + && self.0.max_streams > current + && self.0.connection_stub.0.current_max_send_streams() > current } pub fn is_idle(&self) -> bool { -- cgit v1.2.3