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

Fix AddRef() usage #924

Merged
merged 2 commits into from
Jul 30, 2016
Merged

Fix AddRef() usage #924

merged 2 commits into from
Jul 30, 2016

Conversation

UdjinM6
Copy link

@UdjinM6 UdjinM6 commented Jul 30, 2016

Using AddRef() in ConnectNode() for existing connections doesn't feel right considering how refs are released in ThreadSocketHandler(). I guess this could be the reason that sometimes refs stay >0 no matter what and nodes stuck in vNodesDisconnected forever which means that node never get deleted and FinalizeNode signal is never fired which in its turn means that for example mapBlocksInFlight can't be cleaned properly and then blocks stuck.

This commit should solve the issue by:

  • removing AddRef() for existing connections
  • adding AddRef() in CNode's constructor using the same conditions as in ThreadSocketHandler()
  • addding AddRef() in ConnectNode() and Release() in ThreadSocketHandler() for mixing nodes
  • removing explicit calls to Release() (back to pnode->fDisconnect = true in CMasternodeMan::ProcessMasternodeConnections)

Using AddRef() in ConnectNode() for existing connections doesn't feel right considering how refs are released in ThreadSocketHandler(). I guess this could be the reason that sometimes refs stay >0 no matter what and nodes stuck in vNodesDisconnected forever which means that node never get deleted and FinalizeNode signal is never fired which in its turn means that for example mapBlocksInFlight can't be cleaned properly and then blocks stuck.

This commit should solve the issue by:
- removing AddRef() for existing connections
- adding AddRef() in CNode's constructor using the same conditions as in ThreadSocketHandler()
- addding AddRef() in ConnectNode() and Release() in ThreadSocketHandler() for mixing nodes
- removing explicit calls to Release() (back to `pnode->fDisconnect = true` in `CMasternodeMan::ProcessMasternodeConnections`)
@@ -526,11 +526,10 @@ void CMasternodeMan::ProcessMasternodeConnections()

LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes) {
if(pnode->fDarkSendMaster){
if(pnode->fDarkSendMaster) {

Choose a reason for hiding this comment

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

Shouldnt it be "privatesend" while you are at it? :-)

Copy link
Author

Choose a reason for hiding this comment

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

Good point 👍 Actually shouldn't mention any specifics at all and usage was not described correctly imo (was "where" to use rather then "when"/"why") - fixed var names and comments.

Choose a reason for hiding this comment

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

Love it ❤️

@schinzelh
Copy link

utACK

@schinzelh schinzelh merged commit 17dfbde into dashpay:v0.12.1.x Jul 30, 2016
@UdjinM6 UdjinM6 deleted the fixStuckBlocks branch August 28, 2016 12:22
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.

2 participants