write buf again

This commit is contained in:
quininer 2019-02-25 00:23:34 +08:00
parent 163a96b062
commit 02ff36428c

View File

@ -111,11 +111,16 @@ impl<'a, IO: AsyncRead + AsyncWrite, S: Session> Write for Stream<'a, IO, S> {
} }
} }
if len == 0 && !buf.is_empty() { if len != 0 || buf.is_empty() {
// not write zero
Err(io::ErrorKind::WouldBlock.into())
} else {
Ok(len) Ok(len)
} else {
// not write zero
self.session.write(buf)
.and_then(|len| if len != 0 {
Ok(len)
} else {
Err(io::ErrorKind::WouldBlock.into())
})
} }
} }