Skip to content

Commit

Permalink
Merge #5939: fix: avoid hSocket double lock
Browse files Browse the repository at this point in the history
c9ffb72 fix: avoid `hSocket` double lock (UdjinM6)

Pull request description:

  ## 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:
  - [x] 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
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  PastaPastaPasta:
    utACK c9ffb72

Tree-SHA512: 6042d0683bf9b1326a74d73b5b44896a0470865b88e1c686d6eefe55c0d419b11a134474499bb6c9c308af69b2f7c4a60070d4535072304330cb640f91f5e367
  • Loading branch information
PastaPastaPasta committed Mar 19, 2024
2 parents 1c20180 + c9ffb72 commit 26e886a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4237,7 +4237,7 @@ void CConnman::UnregisterEvents(CNode *pnode)
{
#ifdef USE_KQUEUE
if (socketEventsMode == SOCKETEVENTS_KQUEUE) {
LOCK(pnode->cs_hSocket);
AssertLockHeld(pnode->cs_hSocket);
if (pnode->hSocket == INVALID_SOCKET) {
return;
}
Expand All @@ -4255,7 +4255,7 @@ void CConnman::UnregisterEvents(CNode *pnode)
#endif
#ifdef USE_EPOLL
if (socketEventsMode == SOCKETEVENTS_EPOLL) {
LOCK(pnode->cs_hSocket);
AssertLockHeld(pnode->cs_hSocket);
if (pnode->hSocket == INVALID_SOCKET) {
return;
}
Expand Down

0 comments on commit 26e886a

Please sign in to comment.