-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Make connection deduplicator handle cancellations
When a connection attempt is made, `ConnectionDeduplicator::query` would return `None` for the first attempt, and any future attempts will await on the broadcast channel until the first caller calls `ConnectionDeduplicator::complete`. As such, subsequent callers would await forever if the first caller never called `complete`, e.g. because the enclosing task was cancelled, or due to a logic bug. This commit refactors `ConnectionDeduplicator` to store `Weak` references to the broadcast sender in the map, and `query` now returns the only strong reference. This way, if the caller that gets the strong reference is cancelled, the sender will drop and any queued callers will notice. This has the nice side effect of having to properly correlate the `query` and 'complete's, since the result of `query` is needed to complete.
- Loading branch information
Showing
3 changed files
with
142 additions
and
46 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
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