Log an elaborated reason for sending a TCP packet.
Otherwise, it is hard to debug e.g. ACK loops.
This commit is contained in:
parent
888b098dca
commit
1c7ce85004
|
@ -1246,18 +1246,34 @@ impl<'a> TcpSocket<'a> {
|
||||||
// Decide whether we're sending a packet.
|
// Decide whether we're sending a packet.
|
||||||
if self.seq_to_transmit() {
|
if self.seq_to_transmit() {
|
||||||
// If we have data to transmit and it fits into partner's window, do it.
|
// If we have data to transmit and it fits into partner's window, do it.
|
||||||
|
net_trace!("{}:{}:{}: have data to send",
|
||||||
|
self.meta.handle, self.local_endpoint, self.remote_endpoint);
|
||||||
} else if self.ack_to_transmit() {
|
} else if self.ack_to_transmit() {
|
||||||
// If we have data to acknowledge, do it.
|
// If we have data to acknowledge, do it.
|
||||||
|
net_trace!("{}:{}:{}: have data to acknowledge",
|
||||||
|
self.meta.handle, self.local_endpoint, self.remote_endpoint);
|
||||||
} else if self.window_to_update() {
|
} else if self.window_to_update() {
|
||||||
// If we have window length increase to advertise, do it.
|
// If we have window length increase to advertise, do it.
|
||||||
|
net_trace!("{}:{}:{}: have a window update",
|
||||||
|
self.meta.handle, self.local_endpoint, self.remote_endpoint);
|
||||||
} else if self.state == State::Closed {
|
} else if self.state == State::Closed {
|
||||||
// If we need to abort the connection, do it.
|
// If we need to abort the connection, do it.
|
||||||
|
net_trace!("{}:{}:{}: connection abort",
|
||||||
|
self.meta.handle, self.local_endpoint, self.remote_endpoint);
|
||||||
} else if self.timer.should_retransmit(timestamp).is_some() {
|
} else if self.timer.should_retransmit(timestamp).is_some() {
|
||||||
// If we have packets to retransmit, do it.
|
// If we have packets to retransmit, do it.
|
||||||
|
net_trace!("{}:{}:{}: retransmit timer expired",
|
||||||
|
self.meta.handle, self.local_endpoint, self.remote_endpoint);
|
||||||
} else if self.timer.should_keep_alive(timestamp) {
|
} else if self.timer.should_keep_alive(timestamp) {
|
||||||
// If we need to transmit a keep-alive packet, do it.
|
// If we need to transmit a keep-alive packet, do it.
|
||||||
|
net_trace!("{}:{}:{}: keep-alive timer expired",
|
||||||
|
self.meta.handle, self.local_endpoint, self.remote_endpoint);
|
||||||
} else if self.timer.should_close(timestamp) {
|
} else if self.timer.should_close(timestamp) {
|
||||||
// If we have spent enough time in the TIME-WAIT state, close the socket.
|
// If we have spent enough time in the TIME-WAIT state, close the socket.
|
||||||
|
net_trace!("{}:{}:{}: TIME-WAIT timer expired",
|
||||||
|
self.meta.handle, self.local_endpoint, self.remote_endpoint);
|
||||||
|
self.reset();
|
||||||
|
return Err(Error::Exhausted)
|
||||||
} else {
|
} else {
|
||||||
return Err(Error::Exhausted)
|
return Err(Error::Exhausted)
|
||||||
}
|
}
|
||||||
|
@ -1329,20 +1345,9 @@ impl<'a> TcpSocket<'a> {
|
||||||
// We do not transmit anything in the FIN-WAIT-2 state.
|
// We do not transmit anything in the FIN-WAIT-2 state.
|
||||||
State::FinWait2 => return Err(Error::Exhausted),
|
State::FinWait2 => return Err(Error::Exhausted),
|
||||||
|
|
||||||
// We do not transmit data or control flags in the CLOSING state, but we may
|
// We do not transmit data or control flags in the CLOSING or TIME-WAIT states,
|
||||||
// retransmit an ACK.
|
// but we may retransmit an ACK.
|
||||||
State::Closing => (),
|
State::Closing | State::TimeWait => ()
|
||||||
|
|
||||||
// Handling of the TIME-WAIT state is the same as for the CLOSING state, but also
|
|
||||||
// we wait for the timer to expire.
|
|
||||||
State::TimeWait => {
|
|
||||||
if self.timer.should_close(timestamp) {
|
|
||||||
net_trace!("{}:{}:{}: TIME-WAIT timeout",
|
|
||||||
self.meta.handle, self.local_endpoint, self.remote_endpoint);
|
|
||||||
self.reset();
|
|
||||||
return Err(Error::Exhausted)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// There might be more than one reason to send a packet. E.g. the keep-alive timer
|
// There might be more than one reason to send a packet. E.g. the keep-alive timer
|
||||||
|
|
Loading…
Reference in New Issue