fix(client): properly close idle connections after timeout

Additionally fixes if there were idle connections when a `Client` is
dropped.

Only fixes with the no-proto dispatcher, as changing internals for the
tokio-proto dispatcher would be much harder, and it will replace it very
soon.

Closes #1397
This commit is contained in:
Sean McArthur
2017-12-13 16:29:25 -08:00
parent 16aa92cf03
commit 139dc7ab2b
4 changed files with 125 additions and 13 deletions

View File

@@ -511,6 +511,11 @@ where I: AsyncRead + AsyncWrite,
}
pub fn close_and_shutdown(&mut self) -> Poll<(), io::Error> {
try_ready!(self.flush());
self.shutdown()
}
pub fn shutdown(&mut self) -> Poll<(), io::Error> {
match self.io.io_mut().shutdown() {
Ok(Async::NotReady) => Ok(Async::NotReady),
@@ -625,8 +630,7 @@ where I: AsyncRead + AsyncWrite,
#[inline]
fn close(&mut self) -> Poll<(), Self::SinkError> {
try_ready!(self.poll_complete());
self.shutdown()
self.close_and_shutdown()
}
}