Referencing Bitcoin PR description, _"[...] 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. [...]"_ still applies to Zend current codebase:
TLSManager::threadSocketHandler: node in CConnman::vNodes and CConnman::cs_vNodes protected
ThreadSocketHandler: node in CConnman::vNodes and CConnman::cs_vNodes protected
ThreadMessageHandler: reference count >0
CNode::BeginMessage/CNode::AbortMessage/CNode::EndMessage: called in PushMessage, in turn called (directly/indirectly) in ProcessMessages/SendMessages which fall in the case of reference count >0
TRY_LOCK(pnode->cs_inventory, lockInv);: can be linked to Bitcoin PR #19347 (https://github.com/bitcoin/bitcoin/pull/19347), considering the commit message _"[...] The only other places that csinventory can be taken are:
In ProcessMessages() or SendMessages(), when the CNode's nRefCount
must be >0 (see ThreadMessageHandler(), where the refcount is
incremented before calling ProcessMessages() and SendMessages()).
_In a ForEachNode() lambda in PeerLogicValidation::UpdatedBlockTip().
ForEachNode() locks cs_vNodes and calls the function on the CNode
objects in vNodes. [...]"_
in Zend codebase there are some lockings on cs_inventory in ActivateBestChain, RelayAlternativeChain, Relay but they are protected through connman->cs_vNodes, hence the lock can be removed.
Backport of Bitcoin PR #21750 (https://github.com/bitcoin/bitcoin/pull/21750).
Referencing Bitcoin PR description, _"[...] Indeed all locks of
CNode::cs_vSend
are done either when the reference count is >0 or under the protection ofCConnman::cs_vNodes
and the node being inCConnman::vNodes
. [...]"_ still applies to Zend current codebase:TLSManager::threadSocketHandler
: node inCConnman::vNodes
andCConnman::cs_vNodes
protectedThreadSocketHandler
: node inCConnman::vNodes
andCConnman::cs_vNodes
protectedThreadMessageHandler
: reference count >0CNode::BeginMessage
/CNode::AbortMessage
/CNode::EndMessage
: called inPushMessage
, in turn called (directly/indirectly) inProcessMessages
/SendMessages
which fall in the case of reference count >0Regarding the other two locks:
TRY_LOCK(pnode->cs_vRecvMsg, lockRecv);
: will be addressed by backport of Bitcoin PR #9441 (https://github.com/bitcoin/bitcoin/pull/9441)TRY_LOCK(pnode->cs_inventory, lockInv);
: can be linked to Bitcoin PR #19347 (https://github.com/bitcoin/bitcoin/pull/19347), considering the commit message _"[...] The only other places that csinventory can be taken are:ProcessMessages()
orSendMessages()
, when theCNode
'snRefCount
must be >0 (seeThreadMessageHandler()
, where the refcount is incremented before callingProcessMessages()
andSendMessages()
).ForEachNode()
lambda inPeerLogicValidation::UpdatedBlockTip()
.ForEachNode()
lockscs_vNodes
and calls the function on theCNode
objects invNodes
. [...]"_in Zend codebase there are some lockings on
cs_inventory
inActivateBestChain
,RelayAlternativeChain
,Relay
but they are protected throughconnman->cs_vNodes
, hence the lock can be removed.