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

chain: prevent deadlock while notifying RescanFinished for NeutrinoClient #624

Merged
merged 1 commit into from
Jun 11, 2019
Merged

chain: prevent deadlock while notifying RescanFinished for NeutrinoClient #624

merged 1 commit into from
Jun 11, 2019

Conversation

wpaulino
Copy link
Contributor

@wpaulino wpaulino commented Jun 5, 2019

No description provided.

chain/neutrino.go Outdated Show resolved Hide resolved
// 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()
Copy link
Contributor

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 👍

Copy link
Contributor

@cfromknecht cfromknecht left a comment

Choose a reason for hiding this comment

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

LGTM 🦐

case <-rescanQuit:
// We'll need to re-acquire the lock in order for the
// deferred release call to not panic.
s.clientMtx.Lock()
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

return nil
}
s.clientMtx.Lock()
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Heh good catch!

Copy link
Contributor

@halseth halseth left a comment

Choose a reason for hiding this comment

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

LGTM ⚡️

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM ☄️

@Roasbeef Roasbeef merged commit 66a9592 into btcsuite:master Jun 11, 2019
@wpaulino wpaulino deleted the neutrino-rescan-finished-deadlock branch June 11, 2019 03:00
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.

4 participants