Skip to content

Commit

Permalink
Fix premature abandoment of STOP_SENDING transmission
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralith authored and djc committed Feb 25, 2021
1 parent dd67e91 commit 241cc9c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 7 additions & 7 deletions quinn-proto/src/connection/streams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,13 +533,13 @@ impl Streams {
Some(x) => x,
None => break,
};
let stream = match self.recv.get_mut(&frame.id) {
Some(x) => x,
None => continue,
};
if !stream.is_receiving() {
continue;
}
// We may need to transmit STOP_SENDING even for streams whose state we have discarded,
// because we are able to discard local state for stopped streams immediately upon
// receiving FIN, even if the peer still has arbitrarily large amounts of data to
// (re)transmit due to loss or unconventional sending strategy. We could fine-tune this
// a little by dropping the frame if we specifically know the stream's been reset by the
// peer, but we discard that information as soon as the application consumes it, so it
// can't be relied upon regardless.
trace!(stream = %frame.id, "STOP_SENDING");
frame.encode(buf);
retransmits.get_or_create().stop_sending.push(frame);
Expand Down
4 changes: 4 additions & 0 deletions quinn-proto/src/connection/streams/recv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ impl Recv {
self.assembler.clear();
// Issue flow control credit for unread data
let read_credits = self.end - self.assembler.bytes_read();
// This may send a spurious STOP_SENDING if we've already received all data, but it's a bit
// fiddly to distinguish that from the case where we've received a FIN but are missing some
// data that the peer might still be trying to retransmit, in which case a STOP_SENDING is
// still useful.
Ok((read_credits, ShouldTransmit(self.is_receiving())))
}

Expand Down

0 comments on commit 241cc9c

Please sign in to comment.