Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix panic when receiving already reset push promise #597

Merged
merged 1 commit into from Jan 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/proto/streams/recv.rs
Expand Up @@ -786,6 +786,16 @@ impl Recv {
}
}

pub(super) fn maybe_reset_next_stream_id(&mut self, id: StreamId) {
if let Ok(next_id) = self.next_stream_id {
// !Peer::is_local_init should have been called beforehand
debug_assert_eq!(id.is_server_initiated(), next_id.is_server_initiated());
if id >= next_id {
self.next_stream_id = id.next_id();
}
}
}

/// Returns true if the remote peer can reserve a stream with the given ID.
pub fn ensure_can_reserve(&self) -> Result<(), Error> {
if !self.is_push_enabled {
Expand Down
4 changes: 4 additions & 0 deletions src/proto/streams/streams.rs
Expand Up @@ -883,6 +883,10 @@ impl Inner {
// We normally would open this stream, so update our
// next-send-id record.
self.actions.send.maybe_reset_next_stream_id(id);
} else {
// We normally would recv this stream, so update our
// next-recv-id record.
self.actions.recv.maybe_reset_next_stream_id(id);
}

let stream = Stream::new(id, 0, 0);
Expand Down