IrcTransport::poll_complete now polls the ping timer (fixes #115).

This commit is contained in:
Aaron Weiss 2018-02-08 02:21:08 +01:00
parent decfd0b9bc
commit e847cda40a
No known key found for this signature in database
GPG key ID: 047D32DF25DC22EF

View file

@ -108,13 +108,10 @@ where
}
(Async::Ready(None), _) => Ok(Async::Ready(None)),
(Async::Ready(Some(msg)), _) => {
match timer_poll {
Async::Ready(msg) => {
if let Async::Ready(msg) = timer_poll {
assert!(msg.is_some());
self.send_ping()?;
}
Async::NotReady => (),
}
match msg.command {
// Automatically respond to PINGs from the server.
@ -182,6 +179,13 @@ where
self.close()?;
Err(error::IrcError::PingTimeout)
} else {
// If it's time to send a ping, we should do it! This is necessary to ensure that the
// sink half will close even if the stream half closed without a ping timeout.
if let Async::Ready(msg) = self.ping_timer.poll()? {
assert!(msg.is_some());
self.send_ping()?;
}
Ok(self.inner.poll_complete()?)
}
}