diff options
author | Rob Bradford <robert.bradford@intel.com> | 2020-02-19 14:22:30 +0000 |
---|---|---|
committer | Andreea Florescu <andreea.florescu15@gmail.com> | 2020-09-04 17:59:53 +0300 |
commit | f178b08d273558b7f730de14a7f6364aafe821df (patch) | |
tree | 8ba68bb042f60a7d062e3cb9bcfa30b63748539d /src | |
parent | ee5d3d12880229b1bdd17a5129b16b406648f3fc (diff) | |
download | vmm_vhost-f178b08d273558b7f730de14a7f6364aafe821df.tar.gz |
vhost-user: Return error when connection broken
Return an error wen recvmsg() returns without a message using the
libc::ECONNRESET error so that the upper levels will correctly
interpret this as the connection being broken.
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/vhost_user/sock_ctrl_msg.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/vhost_user/sock_ctrl_msg.rs b/src/vhost_user/sock_ctrl_msg.rs index 76d760f..bfc6d53 100644 --- a/src/vhost_user/sock_ctrl_msg.rs +++ b/src/vhost_user/sock_ctrl_msg.rs @@ -182,8 +182,9 @@ fn raw_recvmsg(fd: RawFd, iovecs: &mut [iovec], in_fds: &mut [RawFd]) -> Result< return Err(Error::last()); } + // When the connection is closed recvmsg() doesn't give an explicit error if total_read == 0 && msg.msg_controllen < size_of::<cmsghdr>() { - return Ok((0, 0)); + return Err(Error::new(libc::ECONNRESET)); } let mut cmsg_ptr = msg.msg_control as *mut cmsghdr; |