Skip to content

Commit

Permalink
net: additional disconnection logging
Browse files Browse the repository at this point in the history
Use the word "disconnecting" everywhere for easier grep.
  • Loading branch information
Sjors committed Sep 27, 2023
1 parent c9f2882 commit 266bb16
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1891,7 +1891,7 @@ void CConnman::DisconnectNodes()
// Disconnect any connected nodes
for (CNode* pnode : m_nodes) {
if (!pnode->fDisconnect) {
LogPrint(BCLog::NET, "Network not active, dropping peer=%d\n", pnode->GetId());
LogPrint(BCLog::NET, "Network not active, disconnecting peer=%d\n", pnode->GetId());
pnode->fDisconnect = true;
}
}
Expand Down Expand Up @@ -1966,22 +1966,22 @@ bool CConnman::InactivityCheck(const CNode& node) const
if (!ShouldRunInactivityChecks(node, now)) return false;

if (last_recv.count() == 0 || last_send.count() == 0) {
LogPrint(BCLog::NET, "socket no message in first %i seconds, %d %d peer=%d\n", count_seconds(m_peer_connect_timeout), last_recv.count() != 0, last_send.count() != 0, node.GetId());
LogPrint(BCLog::NET, "socket no message in first %i seconds, %d %d disconnecting peer=%d\n", count_seconds(m_peer_connect_timeout), last_recv.count() != 0, last_send.count() != 0, node.GetId());
return true;
}

if (now > last_send + TIMEOUT_INTERVAL) {
LogPrint(BCLog::NET, "socket sending timeout: %is peer=%d\n", count_seconds(now - last_send), node.GetId());
LogPrint(BCLog::NET, "socket sending timeout: %is, disconnecting peer=%d\n", count_seconds(now - last_send), node.GetId());
return true;
}

if (now > last_recv + TIMEOUT_INTERVAL) {
LogPrint(BCLog::NET, "socket receive timeout: %is peer=%d\n", count_seconds(now - last_recv), node.GetId());
LogPrint(BCLog::NET, "socket receive timeout: %is, disconnecting peer=%d\n", count_seconds(now - last_recv), node.GetId());
return true;
}

if (!node.fSuccessfullyConnected) {
LogPrint(BCLog::NET, "version handshake timeout peer=%d\n", node.GetId());
LogPrint(BCLog::NET, "version handshake timeout, disconnecting peer=%d\n", node.GetId());
return true;
}

Expand Down Expand Up @@ -2108,6 +2108,7 @@ void CConnman::SocketHandlerConnected(const std::vector<CNode*>& nodes,
{
bool notify = false;
if (!pnode->ReceiveMsgBytes({pchBuf, (size_t)nBytes}, notify)) {
LogPrint(BCLog::NET, "receiving message bytes failed for peer=%d\n", pnode->GetId());
pnode->CloseSocketDisconnect();
}
RecordBytesRecv(nBytes);
Expand Down

0 comments on commit 266bb16

Please sign in to comment.