Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shut down the connection when done with it #1381

Merged
merged 1 commit into from
Nov 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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