From 8a3597bc0c19f9a2cb27db2a8c047e3fbceb61f8 Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Sat, 3 Oct 2020 12:18:55 -0700 Subject: [PATCH] Factor out logic to gracelessly kill the connection --- quinn-proto/src/connection/mod.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/quinn-proto/src/connection/mod.rs b/quinn-proto/src/connection/mod.rs index cc7644491..73e7e064d 100644 --- a/quinn-proto/src/connection/mod.rs +++ b/quinn-proto/src/connection/mod.rs @@ -694,10 +694,7 @@ where self.endpoint_events.push_back(EndpointEventInner::Drained); } Timer::Idle => { - self.close_common(); - self.events.push_back(ConnectionError::TimedOut.into()); - self.state = State::Drained; - self.endpoint_events.push_back(EndpointEventInner::Drained); + self.kill(ConnectionError::TimedOut); } Timer::KeepAlive => { trace!("sending keep-alive"); @@ -2945,6 +2942,14 @@ where self.in_flight.ack_eliciting -= u64::from(packet.ack_eliciting); self.spaces[space].in_flight -= u64::from(packet.size); } + + /// Terminate the connection instantly, without sending a close packet + fn kill(&mut self, reason: ConnectionError) { + self.close_common(); + self.events.push_back(reason.into()); + self.state = State::Drained; + self.endpoint_events.push_back(EndpointEventInner::Drained); + } } impl fmt::Debug for Connection