Skip to content

Commit a78d933

Browse files
authored
Stream rapid reset count handling (#54)
1 parent 39b95f2 commit a78d933

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/connection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ impl RecvHalfConnection {
696696
let count = self.0.rst_count.get() + 1;
697697
let streams_count = self.0.streams_count.get();
698698
if streams_count >= 10 && count >= streams_count >> 1 {
699-
Err(Either::Left(ConnectionError::ConcurrencyOverflow))
699+
Err(Either::Left(ConnectionError::StreamResetsLimit))
700700
} else {
701701
self.0.rst_count.set(count);
702702
Ok(())

src/dispatcher.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,12 @@ where
7171
}
7272
Err(Either::Right(err)) => {
7373
let (stream, kind) = err.into_inner();
74-
log::error!("{}: Failed to handle message: {:?}", stream.tag(), stream);
74+
log::error!(
75+
"{}: Failed to handle message, err: {:?} stream: {:?}",
76+
stream.tag(),
77+
kind,
78+
stream
79+
);
7580

7681
stream.set_failed_stream(kind.into());
7782
self.connection

src/error.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ pub enum ConnectionError {
3333
WindowValueOverflow,
3434
#[error("Max concurrent streams count achieved")]
3535
ConcurrencyOverflow,
36+
#[error("Stream rapid reset count achieved")]
37+
StreamResetsLimit,
3638
/// Keep-alive timeout
3739
#[error("Keep-alive timeout")]
3840
KeepaliveTimeout,
@@ -72,6 +74,8 @@ impl ConnectionError {
7274
.set_data("Updated value for window is overflowed"),
7375
ConnectionError::ConcurrencyOverflow => GoAway::new(Reason::FLOW_CONTROL_ERROR)
7476
.set_data("Max concurrent streams count achieved"),
77+
ConnectionError::StreamResetsLimit => GoAway::new(Reason::FLOW_CONTROL_ERROR)
78+
.set_data("Stream rapid reset count achieved"),
7579
ConnectionError::KeepaliveTimeout => {
7680
GoAway::new(Reason::NO_ERROR).set_data("Keep-alive timeout")
7781
}

0 commit comments

Comments
 (0)