Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partially backport Bitcoin PR#9626: Clean up a few CConnman cs_vNodes/CNode things #1591

Merged
merged 2 commits into from
Aug 28, 2017

Conversation

OlegGirko
Copy link

This is partial backport of Bitcoin PR bitcoin#9626.

The main purpose of this backport is to fix locking issues introduced by earlier backported PR.

This backport includes only 2 of 3 original commits. Last commit is omitted because it moves important code from CConnman::ConnectNode() method to CConnman::OpenNetworkConnection(). This code adds newly created CNode to CConnman::vNodes vector and emits InitializeNode signal. Moving this code is OK for Bitcoin because CConnman::ConnectNode() is private there and the only caller of this method is CConnman::OpenNetworkConnection(). Unfortunately, this is not the case in Dash: CConnman::ConnectNode() is called in some places of Dash-specific code, so moving important functionality out if this method will break that code.

Hence, the last commit is not included in this backport. It can be backported separately later after we decide how to refactor Dash-specific code that uses CConnman::ConnectNode().

The original PR description follows.

This should fix the long-standing (read: satoshi-era) bug where we may not delete a node if we try to connect to it (via RPC) after its already connected as we'll have duplicate refs.

This also removes some unused functions (some of which miss a lock, some of which should otherwise be cleaned up for bitcoin#9609).

This also ensures that if we return a CNode* from FindNode, we are still holding cs_vNodes if we use it for anything aside from existance-checking, fixing a stupid-unlikely race where it might be deleted out from under us.

Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@UdjinM6 UdjinM6 added this to the 12.2 milestone Aug 28, 2017
@UdjinM6 UdjinM6 merged commit 1051221 into dashpay:v0.12.2.x Aug 28, 2017
@OlegGirko OlegGirko deleted the bc-pr-9626 branch August 29, 2017 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants