net: clarify if we ever sent or received from peer

This commit is contained in:
Sjors Provoost 2024-11-26 14:01:36 +01:00
parent 1d01ad4d73
commit 06443b8f28
No known key found for this signature in database
GPG key ID: 57FF9BDBCC301009
2 changed files with 11 additions and 6 deletions

View file

@ -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;

View file

@ -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):