diff --git a/protocols/ping/src/lib.rs b/protocols/ping/src/lib.rs index 481eaef5..e8f1cc88 100644 --- a/protocols/ping/src/lib.rs +++ b/protocols/ping/src/lib.rs @@ -226,6 +226,14 @@ where TSocket: AsyncRead + AsyncWrite, type Error = IoError; fn poll(&mut self) -> Poll, Self::Error> { + if self.needs_close { + match self.inner.close() { + Ok(Async::Ready(())) => return Ok(Async::Ready(None)), + Ok(Async::NotReady) => return Ok(Async::NotReady), + Err(err) => return Err(err), + } + } + self.to_notify = Some(task::current()); while let Some((ping, user_data)) = self.pings_to_send.pop_front() { @@ -257,7 +265,7 @@ where TSocket: AsyncRead + AsyncWrite, .expect("Grabbed a valid position just above"); return Ok(Async::Ready(Some(user_data))); } else { - debug!("Received pong that doesn't match what we went: {:?}", pong); + debug!("Received pong that doesn't match what we sent: {:?}", pong); } }, Ok(Async::NotReady) => break,