From fff2f4a73b19559deb4faa4dabf237cde353b2a6 Mon Sep 17 00:00:00 2001 From: quininer Date: Sat, 31 Mar 2018 15:16:31 +0800 Subject: [PATCH] fix(tokio_impl): shutdown WouldBlock --- Cargo.toml | 4 ++-- src/tokio_impl.rs | 8 +++++++- tests/test.rs | 14 ++++++++------ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bc6d23c..a7a1bb5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tokio-rustls" -version = "0.6.0-alpha" +version = "0.6.0-alpha.1" authors = ["quininer kel "] license = "MIT/Apache-2.0" repository = "https://github.com/quininer/tokio-rustls" @@ -24,5 +24,5 @@ webpki = "0.18.0-alpha" tokio = "0.1" [features] -default = [ "unstable-futures", "tokio" ] +default = [ "tokio" ] unstable-futures = [ "futures", "tokio/unstable-futures" ] diff --git a/src/tokio_impl.rs b/src/tokio_impl.rs index f5d3c6c..936c14b 100644 --- a/src/tokio_impl.rs +++ b/src/tokio_impl.rs @@ -64,7 +64,13 @@ impl AsyncWrite for TlsStream self.session.send_close_notify(); self.is_shutdown = true; } - self.session.complete_io(&mut self.io)?; + + match self.session.complete_io(&mut self.io) { + Ok(_) => (), + Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => return Ok(Async::NotReady), + Err(e) => return Err(e) + } + self.io.shutdown() } } diff --git a/tests/test.rs b/tests/test.rs index 92c904a..246e85a 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -73,10 +73,11 @@ fn start_client(addr: &SocketAddr, domain: &str, chain: Option