Page MenuHomePhabricator

net: remove unnecessary check of CNode::cs_vSend
ClosedPublic

Authored by PiRK on Mar 14 2023, 14:31.

Details

Reviewers
sdulfari
Group Reviewers
Restricted Project
Commits
rABC776effe43a75: 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

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable