Skip to content

Commit 5555557

Browse files
author
MarcoFalke
committed
net: Log accepted connection after m_nodes.push_back
Otherwise, the debug log could read confusingly, when the getpeerinfo() RPC (calling GetNodeStats) happens after the "accepted connection" log line, but returns an empty list. For example, the following timeline in the debug log could correspond to a getpeerinfo reply that is empty: [net] [net.cpp:3764] [CNode] Added connection peer=0 [net] [net.cpp:1814] [CreateNodeFromAcceptedSocket] connection from 127.0.0.1:45154 accepted [http] [httpserver.cpp:305] [http_request_cb] Received a POST request for / from 127.0.0.1:33320 [httpworker.1] [rpc/request.cpp:232] [parse] ThreadRPCServer method=getpeerinfo user=__cookie__ Fix it by moving the log line.
1 parent 910d38b commit 5555557

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/net.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,13 +1810,11 @@ void CConnman::CreateNodeFromAcceptedSocket(std::unique_ptr<Sock>&& sock,
18101810
});
18111811
pnode->AddRef();
18121812
m_msgproc->InitializeNode(*pnode, nLocalServices);
1813-
1814-
LogPrint(BCLog::NET, "connection from %s accepted\n", addr.ToStringAddrPort());
1815-
18161813
{
18171814
LOCK(m_nodes_mutex);
18181815
m_nodes.push_back(pnode);
18191816
}
1817+
LogDebug(BCLog::NET, "connection from %s accepted\n", addr.ToStringAddrPort());
18201818

18211819
// We received a new connection, harvest entropy from the time (and our peer count)
18221820
RandAddEvent((uint32_t)id);

0 commit comments

Comments
 (0)