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);
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()
}
}

View File

@ -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<()> {

View File

@ -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<ClientConfig>,
early_data: bool
}
/// A wrapper around a `rustls::ServerConfig`, providing an async `accept` method.
#[derive(Clone)]
pub struct TlsAcceptor {
inner: Arc<ServerConfig>

View File

@ -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()
}
}