Factor out logic to gracelessly kill the connection

This commit is contained in:
Benjamin Saunders
2020-10-03 12:18:55 -07:00
parent dc475d23de
commit 8a3597bc0c
+9 -4
View File
@@ -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<S> fmt::Debug for Connection<S>