Skip to content

Commit a9fa893

Browse files
authoredDec 29, 2023
feat(http2): add max_pending_accept_reset_streams(num) back to HTTP/2 server builder (#3507)
In places where required, the `max_pending_accept_reset_streams` option was reimplemented, as in PR #3201 cc #3461
1 parent 9b5f409 commit a9fa893

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
 

‎src/proto/h2/server.rs

+5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub(crate) struct Config {
4949
pub(crate) max_frame_size: u32,
5050
pub(crate) enable_connect_protocol: bool,
5151
pub(crate) max_concurrent_streams: Option<u32>,
52+
pub(crate) max_pending_accept_reset_streams: Option<usize>,
5253
pub(crate) keep_alive_interval: Option<Duration>,
5354
pub(crate) keep_alive_timeout: Duration,
5455
pub(crate) max_send_buffer_size: usize,
@@ -64,6 +65,7 @@ impl Default for Config {
6465
max_frame_size: DEFAULT_MAX_FRAME_SIZE,
6566
enable_connect_protocol: false,
6667
max_concurrent_streams: Some(200),
68+
max_pending_accept_reset_streams: None,
6769
keep_alive_interval: None,
6870
keep_alive_timeout: Duration::from_secs(20),
6971
max_send_buffer_size: DEFAULT_MAX_SEND_BUF_SIZE,
@@ -131,6 +133,9 @@ where
131133
if let Some(max) = config.max_concurrent_streams {
132134
builder.max_concurrent_streams(max);
133135
}
136+
if let Some(max) = config.max_pending_accept_reset_streams {
137+
builder.max_pending_accept_reset_streams(max);
138+
}
134139
if config.enable_connect_protocol {
135140
builder.enable_connect_protocol();
136141
}

‎src/server/conn/http2.rs

+11
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,17 @@ impl<E> Builder<E> {
120120
}
121121
}
122122

123+
/// Configures the maximum number of pending reset streams allowed before a GOAWAY will be sent.
124+
///
125+
/// This will default to the default value set by the [`h2` crate](https://crates.io/crates/h2).
126+
/// As of v0.4.0, it is 20.
127+
///
128+
/// See <https://github.com/hyperium/hyper/issues/2877> for more information.
129+
pub fn max_pending_accept_reset_streams(&mut self, max: impl Into<Option<usize>>) -> &mut Self {
130+
self.h2_builder.max_pending_accept_reset_streams = max.into();
131+
self
132+
}
133+
123134
/// Sets the [`SETTINGS_INITIAL_WINDOW_SIZE`][spec] option for HTTP2
124135
/// stream-level flow control.
125136
///

0 commit comments

Comments
 (0)
Please sign in to comment.