From 92f59031de9e320be7b5396fbcb2d84dcbf69f94 Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Sat, 19 Jan 2019 14:06:02 -0800 Subject: [PATCH] Stop idle timer when connection starts to close Fixes a bug where the stop would get lost when the connection state is discarded by the endpoint. --- quinn-proto/src/connection.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/quinn-proto/src/connection.rs b/quinn-proto/src/connection.rs index e0a852518..fd7739f39 100644 --- a/quinn-proto/src/connection.rs +++ b/quinn-proto/src/connection.rs @@ -516,7 +516,6 @@ impl Connection { pub fn timeout(&mut self, now: u64, timer: Timer) -> bool { match timer { Timer::Close => { - self.io.timer_stop(Timer::Idle); self.state = State::Drained; return self.app_closed; } @@ -754,6 +753,10 @@ impl Connection { } fn reset_idle_timeout(&mut self, now: u64) { + if self.state.is_closed() { + self.io.timer_stop(Timer::Idle); + return; + } let dt = if self.config.idle_timeout == 0 || self.params.idle_timeout == 0 { cmp::max(self.config.idle_timeout, self.params.idle_timeout) } else {