Skip to content

Commit

Permalink
fix issue#648: drop frame if stream is released (#651)
Browse files Browse the repository at this point in the history
Co-authored-by: p00512853 <pankangtian@huawei.com>
  • Loading branch information
silence-coding and p00512853 committed Dec 2, 2022
1 parent 294000c commit af47a08
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
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

0 comments on commit af47a08

Please sign in to comment.