return an Err when read return 0 (#1503)

* return an Err when read return 0, instead of all zeroed buff without any error
This commit is contained in:
Gary Yu
2018-09-11 19:14:48 +08:00
committed by hashmap
parent dd1cef2148
commit 0dbfed5971
+6 -1
View File
@@ -121,7 +121,12 @@ pub fn read_exact(
let mut read = 0;
loop {
match conn.read(buf) {
Ok(0) => break,
Ok(0) => {
return Err(io::Error::new(
io::ErrorKind::ConnectionAborted,
"read_exact",
));
}
Ok(n) => {
let tmp = buf;
buf = &mut tmp[n..];