Fix error handling for closed channel.

fixes #417
This commit is contained in:
Konstantin Seiler 2020-01-22 16:58:21 +11:00
parent 2a1482c880
commit 362106df62

View file

@ -92,7 +92,8 @@ impl ChannelManager {
impl Channel {
fn recv_packet(&mut self) -> Poll<Bytes, ChannelError> {
let (cmd, packet) = match self.receiver.poll() {
Ok(Async::Ready(t)) => t.expect("channel closed"),
Ok(Async::Ready(Some(t))) => t,
Ok(Async::Ready(None)) => return Err(ChannelError), // The channel has been closed.
Ok(Async::NotReady) => return Ok(Async::NotReady),
Err(()) => unreachable!(),
};