diff --git a/src/net.cpp b/src/net.cpp index fcf17d3f27..c3c472793d 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1982,12 +1982,17 @@ bool CConnman::InactivityCheck(const CNode& node) const if (!ShouldRunInactivityChecks(node, now)) return false; - if (last_recv.count() == 0 || last_send.count() == 0) { + bool has_received{last_recv.count() != 0}; + bool has_sent{last_send.count() != 0}; + + if (!has_received || !has_sent) { + std::string has_never; + if (!has_received) has_never += ", never received from peer"; + if (!has_sent) has_never += ", never sent to peer"; LogDebug(BCLog::NET, - "socket no message in first %i seconds, %d %d, %s\n", + "socket no message in first %i seconds%s, %s\n", count_seconds(m_peer_connect_timeout), - last_recv.count() != 0, - last_send.count() != 0, + has_never, node.DisconnectMsg(fLogIPs) ); return true; diff --git a/test/functional/p2p_timeouts.py b/test/functional/p2p_timeouts.py index b42d940d7b..ce01547887 100755 --- a/test/functional/p2p_timeouts.py +++ b/test/functional/p2p_timeouts.py @@ -91,8 +91,8 @@ class TimeoutsTest(BitcoinTestFramework): else: expected_timeout_logs = [ "version handshake timeout, disconnecting peer=0", - "socket no message in first 3 seconds, 1 0, disconnecting peer=1", - "socket no message in first 3 seconds, 0 0, disconnecting peer=2", + "socket no message in first 3 seconds, never sent to peer, disconnecting peer=1", + "socket no message in first 3 seconds, never received from peer, never sent to peer, disconnecting peer=2", ] with self.nodes[0].assert_debug_log(expected_msgs=expected_timeout_logs):