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 issue#648: drop frame if stream is released #651

Merged
merged 1 commit into from Dec 2, 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 @@ -600,6 +600,16 @@ impl Recv {
}
}

// Received a frame, but no one cared about it. fix issue#648
if !stream.is_recv {
tracing::trace!(
"recv_data; frame ignored on stream release {:?} for some time",
stream.id,
);
self.release_connection_capacity(sz, &mut None);
return Ok(());
}

// Update stream level flow control
stream.recv_flow.send_data(sz);

Expand Down
4 changes: 4 additions & 0 deletions src/proto/streams/stream.rs
Expand Up @@ -99,6 +99,9 @@ pub(super) struct Stream {
/// Frames pending for this stream to read
pub pending_recv: buffer::Deque,

/// When the RecvStream drop occurs, no data should be received.
pub is_recv: bool,

/// Task tracking receiving frames
pub recv_task: Option<Waker>,

Expand Down Expand Up @@ -180,6 +183,7 @@ impl Stream {
reset_at: None,
next_reset_expire: None,
pending_recv: buffer::Deque::new(),
is_recv: true,
recv_task: None,
pending_push_promises: store::Queue::new(),
content_length: ContentLength::Omitted,
Expand Down
3 changes: 2 additions & 1 deletion src/proto/streams/streams.rs
Expand Up @@ -1345,12 +1345,13 @@ impl OpaqueStreamRef {
.release_capacity(capacity, &mut stream, &mut me.actions.task)
}

/// Clear the receive queue and set the status to no longer receive data frames.
pub(crate) fn clear_recv_buffer(&mut self) {
let mut me = self.inner.lock().unwrap();
let me = &mut *me;

let mut stream = me.store.resolve(self.key);

stream.is_recv = false;
me.actions.recv.clear_recv_buffer(&mut stream);
}

Expand Down