From 7056581575e8dc9386b2c42e144286e4bec0140e Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Sun, 28 Apr 2024 19:43:27 -0700 Subject: [PATCH] Fix loss detection timer sometimes lingering after close --- quinn-proto/src/connection/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/quinn-proto/src/connection/mod.rs b/quinn-proto/src/connection/mod.rs index 1ea9f07dc..2de7b8d4f 100644 --- a/quinn-proto/src/connection/mod.rs +++ b/quinn-proto/src/connection/mod.rs @@ -1699,6 +1699,13 @@ impl Connection { } fn set_loss_detection_timer(&mut self, now: Instant) { + if self.state.is_closed() { + // No loss detection takes place on closed connections, and `close_common` already + // stopped time timer. Ensure we don't restart it inadvertently, e.g. in response to a + // reordered packet being handled by state-insensitive code. + return; + } + if let Some((loss_time, _)) = self.loss_time_and_space() { // Time threshold loss detection. self.timers.set(Timer::LossDetection, loss_time);