summary refs log tree commit diff
path: root/src/linux.rs
diff options
context:
space:
mode:
authorZach Reizner <zachr@google.com>2020-02-21 14:45:14 -0800
committerCommit Bot <commit-bot@chromium.org>2020-04-14 23:56:49 +0000
commit297ae77887021445c02861a011a6ebb9143bf6c1 (patch)
tree496d07321d43858905e9094440f551354ac45ab3 /src/linux.rs
parente4cbef4caf66779e5f8734c63fb591c991bf9674 (diff)
downloadcrosvm-297ae77887021445c02861a011a6ebb9143bf6c1.tar
crosvm-297ae77887021445c02861a011a6ebb9143bf6c1.tar.gz
crosvm-297ae77887021445c02861a011a6ebb9143bf6c1.tar.bz2
crosvm-297ae77887021445c02861a011a6ebb9143bf6c1.tar.lz
crosvm-297ae77887021445c02861a011a6ebb9143bf6c1.tar.xz
crosvm-297ae77887021445c02861a011a6ebb9143bf6c1.tar.zst
crosvm-297ae77887021445c02861a011a6ebb9143bf6c1.zip
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 <noreply+kokoro@google.com>
Commit-Queue: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Zach Reizner <zachr@chromium.org>
Diffstat (limited to 'src/linux.rs')
-rw-r--r--src/linux.rs6
1 files changed, 3 insertions, 3 deletions
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);