-
Notifications
You must be signed in to change notification settings - Fork 576
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
chain: prevent deadlock while notifying RescanFinished for NeutrinoClient #624
chain: prevent deadlock while notifying RescanFinished for NeutrinoClient #624
Conversation
// Release the lock while dispatching the notification since | ||
// it's possible for the notificationHandler to be waiting to | ||
// acquire it before receiving the notification. | ||
s.clientMtx.Unlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I think this is an ok solution for now, this should fix the issue I ran into. Longer term we should move to a more granular set of mutexes (or get rid of the mutexes all together), but short term this is fine 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🦐
chain/neutrino.go
Outdated
case <-rescanQuit: | ||
// We'll need to re-acquire the lock in order for the | ||
// deferred release call to not panic. | ||
s.clientMtx.Lock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we instead get rid of the defer and unlock manually on each return case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cfromknecht seems to prefer the defer approach, though that might've been because there were some fields that were being used without the lock in the prior diff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I’m fine with not having a defer, originally thought it’d make a smaller diff but seems not :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
chain/neutrino.go
Outdated
return nil | ||
} | ||
s.clientMtx.Lock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that we are not returning the error on line 391
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ⚡️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ☄️
No description provided.