Skip to content

Commit

Permalink
Shut down the connection when done with it
Browse files Browse the repository at this point in the history
This is important for TLS connections in particular

Closes hyperium#1380
  • Loading branch information
sfackler committed Nov 22, 2017
1 parent e4864a2 commit a356449
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/proto/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,20 @@ where I: AsyncRead + AsyncWrite,

}

pub fn shutdown(&mut self) -> Poll<(), io::Error> {
match self.io.io_mut().shutdown() {
Ok(Async::NotReady) => Ok(Async::NotReady),
Ok(Async::Ready(())) => {
trace!("shut down IO");
Ok(Async::Ready(()))
}
Err(e) => {
debug!("error shutting down IO: {}", e);
Err(e)
}
}
}

pub fn close_read(&mut self) {
self.state.close_read();
}
Expand Down Expand Up @@ -540,10 +554,7 @@ where I: AsyncRead + AsyncWrite,
#[inline]
fn close(&mut self) -> Poll<(), Self::SinkError> {
try_ready!(self.poll_complete());
self.io.io_mut().shutdown().map_err(|err| {
debug!("error closing: {}", err);
err
})
self.shutdown()
}
}

Expand Down
1 change: 1 addition & 0 deletions src/proto/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ where
self.poll_flush()?;

if self.is_done() {
try_ready!(self.conn.shutdown());
trace!("Dispatch::poll done");
Ok(Async::Ready(()))
} else {
Expand Down

0 comments on commit a356449

Please sign in to comment.