diff --git a/src/client.rs b/src/client.rs index 8d6758e..386d242 100644 --- a/src/client.rs +++ b/src/client.rs @@ -187,10 +187,8 @@ where IO: AsyncRead + AsyncWrite } } - { - let mut stream = Stream::new(&mut self.io, &mut self.session); - try_nb!(stream.complete_io()); - } - self.io.shutdown() + let mut stream = Stream::new(&mut self.io, &mut self.session); + try_nb!(stream.complete_io()); + stream.io.shutdown() } } diff --git a/src/common/mod.rs b/src/common/mod.rs index 9010d8d..a88a278 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -110,7 +110,13 @@ impl<'a, IO: AsyncRead + AsyncWrite, S: Session> Write for Stream<'a, IO, S> { Err(err) => return Err(err) } } - Ok(len) + + if len == 0 && !buf.is_empty() { + // not write zero + Err(io::ErrorKind::WouldBlock.into()) + } else { + Ok(len) + } } fn flush(&mut self) -> io::Result<()> { diff --git a/src/lib.rs b/src/lib.rs index 446e80d..511cdd9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,12 +24,14 @@ use tokio_io::{ AsyncRead, AsyncWrite, try_nb }; use common::Stream; +/// A wrapper around a `rustls::ClientConfig`, providing an async `connect` method. #[derive(Clone)] pub struct TlsConnector { inner: Arc, early_data: bool } +/// A wrapper around a `rustls::ServerConfig`, providing an async `accept` method. #[derive(Clone)] pub struct TlsAcceptor { inner: Arc diff --git a/src/server.rs b/src/server.rs index 42dd18d..fd02a35 100644 --- a/src/server.rs +++ b/src/server.rs @@ -130,10 +130,8 @@ where IO: AsyncRead + AsyncWrite, } } - { - let mut stream = Stream::new(&mut self.io, &mut self.session); - try_nb!(stream.complete_io()); - } - self.io.shutdown() + let mut stream = Stream::new(&mut self.io, &mut self.session); + try_nb!(stream.complete_io()); + stream.io.shutdown() } }