mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
[net processing] Improve documentation for Peer destruction/locking
Suggested here: - https://github.com/bitcoin/bitcoin/pull/19607#discussion_r467071878 - https://github.com/bitcoin/bitcoin/pull/19829#discussion_r546116786
This commit is contained in:
parent
f1dbf92ff0
commit
717a374e74
2 changed files with 9 additions and 1 deletions
|
|
@ -791,6 +791,11 @@ void PeerManager::FinalizeNode(const CNode& node, bool& fUpdateConnectionTime) {
|
|||
LOCK(cs_main);
|
||||
int misbehavior{0};
|
||||
{
|
||||
// We remove the PeerRef from g_peer_map here, but we don't always
|
||||
// destruct the Peer. Sometimes another thread is still holding a
|
||||
// PeerRef, so the refcount is >= 1. Be careful not to do any
|
||||
// processing here that assumes Peer won't be changed before it's
|
||||
// destructed.
|
||||
PeerRef peer = RemovePeer(nodeid);
|
||||
assert(peer != nullptr);
|
||||
misbehavior = WITH_LOCK(peer->m_misbehavior_mutex, return peer->m_misbehavior_score);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue