Log connection states explicitly

This commit is contained in:
Floris Bruynooghe
2025-12-19 09:51:11 +01:00
parent c8f55101b5
commit 8b6f76cc0e
2 changed files with 11 additions and 3 deletions
-1
View File
@@ -3831,7 +3831,6 @@ impl Connection {
self.stats.frame_rx.record(&frame);
if let Frame::Close(_error) = frame {
trace!("draining");
self.state.move_to_draining(None);
break;
}
+11 -2
View File
@@ -1,7 +1,10 @@
use bytes::Bytes;
use tracing::trace;
use crate::frame::Close;
use crate::{ApplicationClose, ConnectionClose, ConnectionError, TransportError, TransportErrorCode};
use crate::{
ApplicationClose, ConnectionClose, ConnectionError, TransportError, TransportErrorCode,
};
#[allow(unreachable_pub)] // fuzzing only
#[derive(Debug, Clone)]
@@ -54,13 +57,15 @@ impl State {
pub(super) fn move_to_handshake(&mut self, hs: Handshake) {
self.inner = InnerState::Handshake(hs);
trace!("connection state: handshake");
}
pub(super) fn move_to_established(&mut self) {
self.inner = InnerState::Established;
trace!("connection state: established");
}
/// Moves to a draining state.
/// Moves to the drained state.
///
/// Panics if the state was already drained.
pub(super) fn move_to_drained(&mut self, error: Option<ConnectionError>) {
@@ -93,6 +98,7 @@ impl State {
(error, self.is_local_close())
};
self.inner = InnerState::Drained { error, is_local };
trace!("connection state: drained");
}
/// Moves to a draining state.
@@ -109,6 +115,7 @@ impl State {
);
let is_local = self.is_local_close();
self.inner = InnerState::Draining { error, is_local };
trace!("connection state: draining");
}
fn is_local_close(&self) -> bool {
@@ -138,6 +145,7 @@ impl State {
remote_reason: reason.into(),
is_local: false,
};
trace!("connection state: closed");
}
/// Moves to a closed state after a local error.
@@ -157,6 +165,7 @@ impl State {
remote_reason: reason.into(),
is_local: true,
};
trace!("connection state: closed");
}
pub(super) fn is_handshake(&self) -> bool {