fix: not write zero

This commit is contained in:
quininer 2019-02-23 01:38:55 +08:00
parent 8b8647b43d
commit 681cbe68ca
4 changed files with 15 additions and 11 deletions

View File

@ -187,10 +187,8 @@ where IO: AsyncRead + AsyncWrite
} }
} }
{
let mut stream = Stream::new(&mut self.io, &mut self.session); let mut stream = Stream::new(&mut self.io, &mut self.session);
try_nb!(stream.complete_io()); try_nb!(stream.complete_io());
} stream.io.shutdown()
self.io.shutdown()
} }
} }

View File

@ -110,8 +110,14 @@ impl<'a, IO: AsyncRead + AsyncWrite, S: Session> Write for Stream<'a, IO, S> {
Err(err) => return Err(err) Err(err) => return Err(err)
} }
} }
if len == 0 && !buf.is_empty() {
// not write zero
Err(io::ErrorKind::WouldBlock.into())
} else {
Ok(len) Ok(len)
} }
}
fn flush(&mut self) -> io::Result<()> { fn flush(&mut self) -> io::Result<()> {
self.session.flush()?; self.session.flush()?;

View File

@ -24,12 +24,14 @@ use tokio_io::{ AsyncRead, AsyncWrite, try_nb };
use common::Stream; use common::Stream;
/// A wrapper around a `rustls::ClientConfig`, providing an async `connect` method.
#[derive(Clone)] #[derive(Clone)]
pub struct TlsConnector { pub struct TlsConnector {
inner: Arc<ClientConfig>, inner: Arc<ClientConfig>,
early_data: bool early_data: bool
} }
/// A wrapper around a `rustls::ServerConfig`, providing an async `accept` method.
#[derive(Clone)] #[derive(Clone)]
pub struct TlsAcceptor { pub struct TlsAcceptor {
inner: Arc<ServerConfig> inner: Arc<ServerConfig>

View File

@ -130,10 +130,8 @@ where IO: AsyncRead + AsyncWrite,
} }
} }
{
let mut stream = Stream::new(&mut self.io, &mut self.session); let mut stream = Stream::new(&mut self.io, &mut self.session);
try_nb!(stream.complete_io()); try_nb!(stream.complete_io());
} stream.io.shutdown()
self.io.shutdown()
} }
} }