Skip to content

net, net_processing: additional and consistent disconnect logging

While debugging unexpected disconnections, possibly related to #28331, I found some additional [net] logging to be useful.

All cases where we disconnect now come with a log message that has the word disconnecting:

  • all calls to CloseSocketDisconnect() log disconnecting peer=…
  • wherever we set pnode->fDisconnect = true;
  • for all InactivityCheck cases (which in turn sets fDisconnect)
  • replaces "dropping" with "disconnecting" in Network not active, dropping peer=…

A few exceptions are listed here: https://github.com/bitcoin/bitcoin/pull/28521#discussion_r1890824361

I changed CloseSocketDisconnect() to no longer log disconnecting, and instead have all the call sites do so.

This PR introduces two helper functions on CNode: DisconnectMsg and LogIP. The second and third commit use these helpers in net_processing.cpp so these disconnect messages are more consistent now (e.g. some didn't log the IP). No new messages are added there though.

The LogIP() helper is rarely used outside of a disconnect event, but it's available for future use.

Any LogPrint this PR touches is replaced with LogDebug (superseded by #30750), and every LogPrintf with LogInfo.

Merge request reports

Loading