Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid an open Peer with a closed Client (flutter#65)
May fix dart-lang/sdk#43012 If a `Peer` is created with a `StreamChannel` that does not follow the stated contract it's possible that the `sink` gets closed without receiving a done event from the `channel` which leaves the `Peer` instance in a state that's inconsistent with the underlying `Client`. The result is that it's possible to get a bad state trying to send a message even with `isClosed` returns `false`. - Make `isClosed` and `done` forward to the `_client` and `_peer` fields so that they can't be inconsistent. - Forward errors to the `_server` so that it can forward them through `done` without an extra `Completer` to manage. - Avoid closing the `sink` in the `Peer`. It will end up being closed by the server when it is handling the error, and it's the same `sink` instance in both places. - Add a test that ensures that `isClosed` behaves as expected following a call to `close()` even when the `StreamChannel` does not follow it's contract.
- Loading branch information