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