vhost_rs: 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>
This commit is contained in:
Rob Bradford 2020-02-19 14:22:30 +00:00
parent c49e31a6d9
commit b5755e9c33

View File

@ -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;