From 825d6463c3d872f4efadc2d5e97ea1a11323dd49 Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Sat, 18 May 2024 12:04:10 -0700 Subject: [PATCH] Don't send stream-level flow control updates for stopped streams 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. --- quinn-proto/src/connection/streams/recv.rs | 3 ++- quinn-proto/src/connection/streams/state.rs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/quinn-proto/src/connection/streams/recv.rs b/quinn-proto/src/connection/streams/recv.rs index 509148039..d968fd4e4 100644 --- a/quinn-proto/src/connection/streams/recv.rs +++ b/quinn-proto/src/connection/streams/recv.rs @@ -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)) } diff --git a/quinn-proto/src/connection/streams/state.rs b/quinn-proto/src/connection/streams/state.rs index c71a7e728..21d585a63 100644 --- a/quinn-proto/src/connection/streams/state.rs +++ b/quinn-proto/src/connection/streams/state.rs @@ -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( @@ -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);