Skip to content

Commit

Permalink
Log more information during an idle timeout
Browse files Browse the repository at this point in the history
Show current state, handle the case when there were dual FIN's and an
ACK got dropped (doesn't need a scary WARN log).
  • Loading branch information
carver committed Jun 21, 2023
1 parent 9595728 commit 4591003
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,24 @@ impl<const N: usize, P: ConnectionPeer> Connection<N, P> {
}
() = &mut idle_timeout => {
if !std::matches!(self.state, State::Closed { .. }) {
// Warn that we are giving up on the connection due to a lack of activity.

// First, we look for this special situation:
// Our outgoing FIN was sent, but the incoming ACK was dropped.
// This timeout is not worthy of a warning log, because everything
// basically went fine: all data was sent and ACK'd.
// There is no more work to do.

let unacked: Vec<u16> = self.unacked.keys().copied().collect();
tracing::warn!(?unacked, "idle timeout expired, closing...");
if let State::Closing { local_fin, remote_fin, .. } = self.state {
if unacked.len() == 1 && local_fin.is_some() && &local_fin.unwrap() == unacked.last().unwrap() && remote_fin.is_some() {
tracing::debug!(?self.state, ?unacked, "Idle timeout with both FINs sent, with only FIN unacked.");
} else {
tracing::warn!(?self.state, ?unacked, "quitting idle connection...");
}
} else {
tracing::warn!(?self.state, ?unacked, "quitting idle connection...");
}

self.state = State::Closed { err: Some(Error::TimedOut) };
}
Expand Down

0 comments on commit 4591003

Please sign in to comment.