From 7dc583e3d8325a6bf6b23dc2f8dac7f9b6f3d8a2 Mon Sep 17 00:00:00 2001 From: Daniel Gallups Date: Thu, 28 Dec 2023 18:07:17 -0500 Subject: [PATCH] feat(server|http2): add `max_pending_accept_reset_streams` back to `Config` In places where required, the `max_pending_accept_reset_streams` option was reimplemented, as in PR #3201 May close #3461 --- src/proto/h2/server.rs | 5 +++++ src/server/conn/http2.rs | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/proto/h2/server.rs b/src/proto/h2/server.rs index 33f76344cc..c7d9cc0826 100644 --- a/src/proto/h2/server.rs +++ b/src/proto/h2/server.rs @@ -49,6 +49,7 @@ pub(crate) struct Config { pub(crate) max_frame_size: u32, pub(crate) enable_connect_protocol: bool, pub(crate) max_concurrent_streams: Option, + pub(crate) max_pending_accept_reset_streams: Option, pub(crate) keep_alive_interval: Option, pub(crate) keep_alive_timeout: Duration, pub(crate) max_send_buffer_size: usize, @@ -64,6 +65,7 @@ impl Default for Config { max_frame_size: DEFAULT_MAX_FRAME_SIZE, enable_connect_protocol: false, max_concurrent_streams: Some(200), + max_pending_accept_reset_streams: None, keep_alive_interval: None, keep_alive_timeout: Duration::from_secs(20), max_send_buffer_size: DEFAULT_MAX_SEND_BUF_SIZE, @@ -131,6 +133,9 @@ where if let Some(max) = config.max_concurrent_streams { builder.max_concurrent_streams(max); } + if let Some(max) = config.max_pending_accept_reset_streams { + builder.max_pending_accept_reset_streams(max); + } if config.enable_connect_protocol { builder.enable_connect_protocol(); } diff --git a/src/server/conn/http2.rs b/src/server/conn/http2.rs index a4fd1ede4f..70c1ee1fe8 100644 --- a/src/server/conn/http2.rs +++ b/src/server/conn/http2.rs @@ -120,6 +120,17 @@ impl Builder { } } + /// Configures the maximum number of pending reset streams allowed before a GOAWAY will be sent. + /// + /// This will default to the default value set by the [`h2` crate](https://crates.io/crates/h2). + /// As of v0.4.0, it is 20. + /// + /// See for more information. + pub fn max_pending_accept_reset_streams(&mut self, max: impl Into>) -> &mut Self { + self.h2_builder.max_pending_accept_reset_streams = max.into(); + self + } + /// Sets the [`SETTINGS_INITIAL_WINDOW_SIZE`][spec] option for HTTP2 /// stream-level flow control. ///