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: avoid hSocket double lock #5939

Merged
1 commit merged into from
Mar 19, 2024
Merged

fix: avoid hSocket double lock #5939

1 commit merged into from
Mar 19, 2024

Conversation

UdjinM6
Copy link

@UdjinM6 UdjinM6 commented Mar 16, 2024

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.
@@ -4237,7 +4237,7 @@ void CConnman::UnregisterEvents(CNode *pnode)
{
#ifdef USE_KQUEUE
if (socketEventsMode == SOCKETEVENTS_KQUEUE) {
LOCK(pnode->cs_hSocket);
AssertLockHeld(pnode->cs_hSocket);
Copy link
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
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

Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

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