This repository was archived by the owner on Oct 28, 2024. It is now read-only.
Avoid an open Peer with a closed Client #65
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
May fix dart-lang/sdk#43012
If a
Peer
is created with aStreamChannel
that does not follow thestated contract it's possible that the
sink
gets closed withoutreceiving a done event from the
channel
which leaves thePeer
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
returnsfalse
.isClosed
anddone
forward to the_client
and_peer
fieldsso that they can't be inconsistent.
_server
so that it can forward them throughdone
without an extraCompleter
to manage.sink
in thePeer
. It will end up being closed bythe server when it is handling the error, and it's the same
sink
instance in both places.
isClosed
behaves as expected followinga call to
close()
even when theStreamChannel
does not follow it'scontract.