From 02ff36428ce1680465514920f1e3d061e03a0b66 Mon Sep 17 00:00:00 2001 From: quininer Date: Mon, 25 Feb 2019 00:23:34 +0800 Subject: [PATCH] write buf again --- src/common/mod.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/common/mod.rs b/src/common/mod.rs index c150189..e4e25cb 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -111,11 +111,16 @@ impl<'a, IO: AsyncRead + AsyncWrite, S: Session> Write for Stream<'a, IO, S> { } } - if len == 0 && !buf.is_empty() { - // not write zero - Err(io::ErrorKind::WouldBlock.into()) - } else { + if len != 0 || buf.is_empty() { Ok(len) + } else { + // not write zero + self.session.write(buf) + .and_then(|len| if len != 0 { + Ok(len) + } else { + Err(io::ErrorKind::WouldBlock.into()) + }) } }