From 6a0228fcc9ad9f147180f0216e32ef1350d203de Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Mon, 30 Oct 2023 13:45:34 +1100 Subject: [PATCH] Check `is_fully_acked` before failing `finish` --- quinn-proto/src/connection/streams/send.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/quinn-proto/src/connection/streams/send.rs b/quinn-proto/src/connection/streams/send.rs index 88b7187a6..9d4865d56 100644 --- a/quinn-proto/src/connection/streams/send.rs +++ b/quinn-proto/src/connection/streams/send.rs @@ -37,6 +37,19 @@ impl Send { pub(super) fn finish(&mut self) -> Result<(), FinishError> { if let Some(error_code) = self.stop_reason { + // Remote has already stopped the stream .. + + if self.pending.is_fully_acked() { + // All data we sent was already acked + + tracing::debug!(%error_code, "Stream is already stopped"); + self.state = SendState::DataSent { + finish_acked: true, // Pretend that the remote acked the `FIN`. Actually trying to send it would fail because the remote has stopped the stream already. + }; + + return Ok(()) + } + return Err(FinishError::Stopped(error_code)) }