Skip to content

Commit

Permalink
fix: panicked when a reset stream would decrement twice
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed May 25, 2023
1 parent f126229 commit 04e6398
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
9 changes: 0 additions & 9 deletions src/proto/streams/recv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -859,15 +859,6 @@ impl Recv {

tracing::trace!("enqueue_reset_expiration; {:?}", stream.id);

if !counts.can_inc_num_reset_streams() {
// try to evict 1 stream if possible
// if max allow is 0, this won't be able to evict,
// and then we'll just bail after
if let Some(evicted) = self.pending_reset_expired.pop(stream.store_mut()) {
counts.transition_after(evicted, true);
}
}

if counts.can_inc_num_reset_streams() {
counts.inc_num_reset_streams();
self.pending_reset_expired.push(stream);
Expand Down
12 changes: 6 additions & 6 deletions tests/h2-tests/tests/stream_states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -750,14 +750,14 @@ async fn rst_stream_max() {
srv.recv_frame(frames::reset(1).cancel()).await;
srv.recv_frame(frames::reset(3).cancel()).await;
// sending frame after canceled!
// newer streams trump older streams
// 3 is still being ignored
srv.send_frame(frames::data(3, vec![0; 16]).eos()).await;
// olders streams trump newer streams
// 1 is still being ignored
srv.send_frame(frames::data(1, vec![0; 16]).eos()).await;
// ping pong to be sure of no goaway
srv.ping_pong([1; 8]).await;
// 1 has been evicted, will get a reset
srv.send_frame(frames::data(1, vec![0; 16]).eos()).await;
srv.recv_frame(frames::reset(1).stream_closed()).await;
// 3 has been evicted, will get a reset
srv.send_frame(frames::data(3, vec![0; 16]).eos()).await;
srv.recv_frame(frames::reset(3).stream_closed()).await;
};

let client = async move {
Expand Down

0 comments on commit 04e6398

Please sign in to comment.