-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add proxy waiters to allow the Stream to trigger AsyncWrite oper… (#6)
* Updates for tokio master * More logging * Remove trace on start send * Update to tokio 0.2 release * Run travis with stable Rust toolchain again * Add proxy waiters to allow the Stream to trigger AsyncWrite operations As a side effect also gets rid of unsafe code and raw pointers. We have the problem that external read operations (i.e. the Stream impl) can trigger both read (AsyncRead) and write (AsyncWrite) operations on the underyling stream. At the same time write operations (i.e. the Sink impl) can trigger write operations (AsyncWrite) too. Both the Stream and the Sink can be used on two different tasks, but it is required that AsyncRead and AsyncWrite are only ever used by a single task (or better: with a single waker) at a time. Doing otherwise would cause only the latest waker to be remembered, so in our case either the Stream or the Sink impl would potentially wait forever to be woken up because only the other one would've been woken up. To solve this we implement a waker proxy that has two slots (one for read, one for write) to store wakers. One waker proxy is always passed to the AsyncRead, the other to AsyncWrite so that they will only ever have to store a single waker, but internally we dispatch any wakeups to up to two actual wakers (one from the Sink impl and one from the Stream impl). * Remove WebSocketStream::send() The same functionality is already provided via StreamExt::send() and unlike the custom implementation it handles WouldBlock correctly and not as an error. * Remove custom WebSocketStream::close() implementation Instead simply send an owned Closed message. This simplifies the code and among other things also handles errors like WouldBlock correctly instead of handling them like a real error. * Update dependencies * Remove unused #[pin_project] attribute * Use #[pin_project] in stream implementation to get rid of remaining unsafe code Now the whole crate has no unsafe code left. * Depend only on the necessary tokio features instead of "full" Reduces the number of dependencies and code to compile. Based on a PR by Maksym Vorobiov. * Remove unused bytes dependency
- Loading branch information
Showing
13 changed files
with
174 additions
and
197 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
language: rust | ||
rust: | ||
- nightly-2019-09-05 | ||
- stable | ||
|
||
before_script: | ||
- export PATH="$PATH:$HOME/.cargo/bin" | ||
|
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
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
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.