From b5755e9c33d6b7275893037f7dc9e3864445ea0c Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 19 Feb 2020 14:22:30 +0000 Subject: [PATCH] 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 --- vhost_rs/src/vhost_user/sock_ctrl_msg.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vhost_rs/src/vhost_user/sock_ctrl_msg.rs b/vhost_rs/src/vhost_user/sock_ctrl_msg.rs index 76d760f47..bfc6d539d 100644 --- a/vhost_rs/src/vhost_user/sock_ctrl_msg.rs +++ b/vhost_rs/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::() { - return Ok((0, 0)); + return Err(Error::new(libc::ECONNRESET)); } let mut cmsg_ptr = msg.msg_control as *mut cmsghdr;