From 297ae77887021445c02861a011a6ebb9143bf6c1 Mon Sep 17 00:00:00 2001 From: Zach Reizner Date: Fri, 21 Feb 2020 14:45:14 -0800 Subject: msg_socket: add specialized error for zero sized recv Receiving no data can be considered a special case for MsgOnSocket. It doesn't necessarily indicate EOF because usually messages are sent over a datagram channel and some fixed sized messages are actually zero sized. This change handles this by adding a specific result for receiving no data when at least some was expected. This will also simplify some error handling that had to unpack the `BadRecvSize` variant. TEST=cargo test -p msg_socket BUG=None Change-Id: I16feeabc1481de93a2b189989d095434b5b417b5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2079178 Tested-by: kokoro Commit-Queue: Zach Reizner Reviewed-by: Daniel Verkamp Auto-Submit: Zach Reizner --- src/linux.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/linux.rs') diff --git a/src/linux.rs b/src/linux.rs index 9dbdb5c..a5af858 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -2024,7 +2024,7 @@ fn run_control( } } Err(e) => { - if let MsgError::BadRecvSize { actual: 0, .. } = e { + if let MsgError::RecvZero = e { vm_control_indices_to_remove.push(index); } else { error!("failed to recv VmRequest: {}", e); @@ -2040,7 +2040,7 @@ fn run_control( } } Err(e) => { - if let MsgError::BadRecvSize { actual: 0, .. } = e { + if let MsgError::RecvZero = e { vm_control_indices_to_remove.push(index); } else { error!("failed to recv VmMemoryControlRequest: {}", e); @@ -2056,7 +2056,7 @@ fn run_control( } } Err(e) => { - if let MsgError::BadRecvSize { actual: 0, .. } = e { + if let MsgError::RecvZero = e { vm_control_indices_to_remove.push(index); } else { error!("failed to recv VmIrqRequest: {}", e); -- cgit 1.4.1