-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix deadlock in chain tip watch channel (#3378)
* Avoid sequential borrows in `LatestChainTip` Calling `watch::Receiver::borrow` more than once in the same scope can cause a deadlock. The instrumented methods were calling `borrow` twice to record instrumented fields. This refactors things to ensure `borrow` is only called once to record the fields and perform any actions with the chain tip block. * Remove `borrow()` calls in `ChainTipChange` Refactor to use a `LatestChainTip` instance instead, which safely protects the internal `watch::Receiver` so that it is not borrowed more than once in the same scope. * Add a paragraph to the Asynchronous guide Warn against using two borrow guards in the same scope, and describe why that can lead to a deadlock.
- Loading branch information
Showing
2 changed files
with
107 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters