-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: avoid race condition between pending frames and closing stream (#…
…156) Currently, we have a `garbage_collect` function that checks whether any of our streams have been dropped. This can cause a race condition where the channel between a `Stream` and the `Connection` still has pending frames for a stream but dropping a stream causes us to already send a `FIN` flag for the stream. We fix this by maintaining a single channel for each stream. When a stream gets dropped, the `Receiver` becomes disconnected. We use this information to queue the correct frame (`FIN` vs `RST`) into the buffer. At this point, all previous frames have already been processed and the race condition is thus not present. Additionally, this also allows us to implement `Stream::poll_flush` by forwarding to the underlying `Sender`. Note that at present day, this only checks whether there is _space_ in the channel, not whether the items have been emitted by the `Receiver`. We have a PR upstream that might fix this: rust-lang/futures-rs#2746 Fixes: #117.
- Loading branch information
1 parent
88ed4df
commit 52c725b
Showing
8 changed files
with
212 additions
and
167 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,3 @@ log = "0.4.17" | |
[dev-dependencies] | ||
env_logger = "0.10" | ||
constrained-connection = "0.1" | ||
|
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
Oops, something went wrong.