Skip to content

Commit

Permalink
Don't send stream-level flow control updates for stopped streams
Browse files Browse the repository at this point in the history
We only queue MAX_STREAM_DATA when stream data is read by the
application, which never happens for stopped streams, but loss of
packets carrying previously sent MAX_STREAM_DATA frames could still
cause fresh ones to be queued unnecessarily. Filtering them out isn't
strictly necessary, but saves some space in the packet.
  • Loading branch information
Ralith committed May 19, 2024
1 parent b529d6d commit 825d646
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion quinn-proto/src/connection/streams/recv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ impl Recv {
// smaller than `stream_receive_window` in order to make sure the stream
// does not get stuck.
let diff = max_stream_data - self.sent_max_stream_data;
let transmit = self.receiving_unknown_size() && diff >= (stream_receive_window / 8);
let transmit =
self.receiving_unknown_size() && !self.stopped && diff >= (stream_receive_window / 8);
(max_stream_data, ShouldTransmit(transmit))
}

Expand Down
4 changes: 2 additions & 2 deletions quinn-proto/src/connection/streams/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ impl StreamsState {
self.recv
.get(&id)
.and_then(|s| s.as_ref())
.map_or(false, |s| s.receiving_unknown_size())
.map_or(false, |s| s.receiving_unknown_size() && !s.stopped)
}

pub(in crate::connection) fn write_control_frames(
Expand Down Expand Up @@ -446,7 +446,7 @@ impl StreamsState {
Some(x) => x,
None => continue,
};
if !rs.receiving_unknown_size() {
if !rs.receiving_unknown_size() || rs.stopped {
continue;
}
retransmits.get_or_create().max_stream_data.insert(id);
Expand Down

0 comments on commit 825d646

Please sign in to comment.