-
Notifications
You must be signed in to change notification settings - Fork 793
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[net] Make cs_inventory nonrecursive
Summary: > [net processing] Remove PushBlockInventory and PushBlockHash > > PushBlockInventory() and PushBlockHash() are functions that can > be replaced with single-line statements. This also eliminates > the single place that cs_inventory is taken recursively. > [net] Make cs_inventory a non-recursive mutex > > cs_inventory is never taken recursively. Make it a non-recursive mutex. > [net] Don't try to take cs_inventory before deleting CNode > > The TRY_LOCK(cs_inventory) in DisconnectNodes() is taken after the CNode > object has been removed from vNodes and when the CNode's nRefCount is > zero. > > The only other places that cs_inventory 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. > > Therefore, cs_inventory is never locked by another thread when the > TRY_LOCK(cs_inventory) is reached in DisconnectNodes(). Since the > only purpose of this TRY_LOCK is to ensure that the lock is not > taken by another thread, this always succeeds. Remove the check. This is a backport of [[bitcoin/bitcoin#19347 | core#19347]] Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D9433
- Loading branch information
Showing
3 changed files
with
10 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters