Skip to content

Commit

Permalink
fix(server): allow TLS shutdown before dropping connections with no_p…
Browse files Browse the repository at this point in the history
…roto

This is important for TLS connections in particular

Closes #1380
  • Loading branch information
sfackler authored and seanmonstar committed Nov 28, 2017
1 parent 8e7af7b commit 60d0eaf
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
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
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 60d0eaf

Please sign in to comment.