diff options
author | Tom Smeding <tom.smeding@gmail.com> | 2020-03-28 21:23:05 +0100 |
---|---|---|
committer | Tom Smeding <tom.smeding@gmail.com> | 2020-03-28 21:30:34 +0100 |
commit | 58dbe88ca932b4c998d8d012e88b3b5bd575edc5 (patch) | |
tree | c0e680efb9d599d648a81d2a0879c3336ddc0050 | |
parent | fd421e32780cad46782c16cd4e15947f295a08c7 (diff) |
controller/utils: Properly handle short reads on socket
-rw-r--r-- | controller/src/lib.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/controller/src/lib.rs b/controller/src/lib.rs index ee02b3b..b53502f 100644 --- a/controller/src/lib.rs +++ b/controller/src/lib.rs @@ -35,7 +35,7 @@ async fn send_vectored( async fn receive_message(reader: &mut (impl AsyncReadExt + Unpin)) -> io::Result<Option<RawMessage>> { let mut header = [0u8; 17]; - if let Err(e) = reader.read(&mut header).await { + if let Err(e) = reader.read_exact(&mut header).await { if e.kind() == ErrorKind::UnexpectedEof { return Ok(None); } else { return Err(e); } } @@ -46,7 +46,7 @@ async fn receive_message(reader: &mut (impl AsyncReadExt + Unpin)) let mut payload = Vec::new(); payload.resize(length, 0u8); - if let Err(e) = reader.read(&mut payload).await { + if let Err(e) = reader.read_exact(&mut payload).await { if e.kind() == ErrorKind::UnexpectedEof { return Ok(None); } else { return Err(e); } } |