From f178b08d273558b7f730de14a7f6364aafe821df Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 19 Feb 2020 14:22:30 +0000 Subject: 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 --- src/vhost_user/sock_ctrl_msg.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') 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::() { - return Ok((0, 0)); + return Err(Error::new(libc::ECONNRESET)); } let mut cmsg_ptr = msg.msg_control as *mut cmsghdr; -- cgit v1.2.3