HomePhabricator

net: remove unnecessary check of CNode::cs_vSend

Description

net: remove unnecessary check of CNode::cs_vSend

Summary:
It is not possible to have a node in CConnman::vNodesDisconnected and
its reference count to be incremented - all CNode::AddRef() are done
either before the node is added to CConnman::vNodes or while holding
CConnman::cs_vNodes and the object being in CConnman::vNodes.

So, the object being in CConnman::vNodesDisconnected and its reference
count being zero means that it is not and will not start to be used by
other threads.

So, the lock of CNode::cs_vSend in CConnman::DisconnectNodes() will
always succeed and is not necessary.

Indeed all locks of CNode::cs_vSend are done either when the reference
count is >0 or under the protection of CConnman::cs_vNodes and the
node being in CConnman::vNodes.

This is a backport of core#21750

Test Plan:
With Debug and TSAN:
ninja all check check-functional

Reviewers: #bitcoin_abc, sdulfari

Reviewed By: #bitcoin_abc, sdulfari

Differential Revision: https://reviews.bitcoinabc.org/D13332

Details

Provenance
Vasil Dimov <vd@FreeBSD.org>Authored on Apr 22 2021, 09:06
PiRKCommitted on Mar 14 2023, 16:53
PiRKPushed on Mar 14 2023, 16:53
Reviewer
Restricted Project
Differential Revision
D13332: net: remove unnecessary check of CNode::cs_vSend
Parents
rABC03266d53e72f: p2p: pass strings to NetPermissions::TryParse functions by const ref
Branches
Unknown
Tags
Unknown