Skip to content

fix: avoid hSocket double lock - #5939

Merged
1 commit merged into
dashpay:developfrom
UdjinM6:pr5511_2
Mar 19, 2024
Merged

1 commit merged into
dashpay:developfrom
UdjinM6:pr5511_2

Conversation

@UdjinM6

@UdjinM6 UdjinM6 commented Mar 16, 2024

Copy link
Copy Markdown

Issue being fixed or feature implemented

It's is locked in CloseSocketDisconnect() already.

To be merged before #5511 or 19915 backport is going to cause issues otherwise.

What was done?

Assert the lock is held already, instead of locking it again.

How Has This Been Tested?

Run tests, run a node on testnet and drop connections to peers

Breaking Changes

n/a

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

It's is locked in `CloseSocketDisconnect()` already.
Comment thread src/net.cpp
#ifdef USE_KQUEUE
if (socketEventsMode == SOCKETEVENTS_KQUEUE) {
LOCK(pnode->cs_hSocket);
AssertLockHeld(pnode->cs_hSocket);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't we add EXCLUSIVE_LOCKS_REQURIED in header?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

We can't do this cause we lock cs_hSocket per node and UnregisterEvents() is a member of CConnman, not CNode

@PastaPastaPasta PastaPastaPasta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

utACK c9ffb72

@PastaPastaPasta PastaPastaPasta closed this pull request by merging all changes into dashpay:develop in 26e886a Mar 19, 2024
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