Mplex: only close the send of new stream channel

This commit is contained in:
mhchia 2020-02-05 21:41:28 +08:00
parent b7c2ec2187
commit 5b03a7ad9f
No known key found for this signature in database
GPG Key ID: 389EFBEA1362589A

View File

@ -137,7 +137,7 @@ class Mplex(IMuxedConn):
"""accepts a muxed stream opened by the other end."""
try:
return await self.new_stream_receive_channel.receive()
except (trio.ClosedResourceError, trio.EndOfChannel):
except trio.EndOfChannel:
raise MplexUnavailable
async def send_message(
@ -254,7 +254,7 @@ class Mplex(IMuxedConn):
mplex_stream = await self._initialize_stream(stream_id, message.decode())
try:
await self.new_stream_send_channel.send(mplex_stream)
except (trio.BrokenResourceError, trio.ClosedResourceError):
except trio.ClosedResourceError:
raise MplexUnavailable
async def _handle_message(self, stream_id: StreamID, message: bytes) -> None:
@ -336,6 +336,4 @@ class Mplex(IMuxedConn):
send_channel = self.streams_msg_channels[stream_id]
await send_channel.aclose()
self.event_closed.set()
# FIXME: It's enough to just close one side.
await self.new_stream_send_channel.aclose()
await self.new_stream_receive_channel.aclose()