From d3392403c250f198eb498d129b1550b90975b809 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Tue, 31 Oct 2023 18:25:33 -0700 Subject: [PATCH] Use `send` instead of `sendmsg` to send with no fds This should fix the failing FreeBSD CI test, and behave correctly. This is perhaps better, though I think either *should* work (https://github.com/bytecodealliance/rustix/issues/914). The other `sendmsg`/`recvmsg` calls use `rustix::cmsg_space!`, and should work without issue. --- wayland-backend/src/rs/socket.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/wayland-backend/src/rs/socket.rs b/wayland-backend/src/rs/socket.rs index 18af97cc37d..739a255af42 100644 --- a/wayland-backend/src/rs/socket.rs +++ b/wayland-backend/src/rs/socket.rs @@ -6,8 +6,8 @@ use std::os::unix::net::UnixStream; use std::slice; use rustix::net::{ - recvmsg, sendmsg, RecvAncillaryBuffer, RecvAncillaryMessage, RecvFlags, SendAncillaryBuffer, - SendAncillaryMessage, SendFlags, + recvmsg, send, sendmsg, RecvAncillaryBuffer, RecvAncillaryMessage, RecvFlags, + SendAncillaryBuffer, SendAncillaryMessage, SendFlags, }; use crate::protocol::{ArgumentType, Message}; @@ -39,9 +39,9 @@ impl Socket { /// end may lose some data. pub fn send_msg(&self, bytes: &[u8], fds: &[RawFd]) -> IoResult { let flags = SendFlags::DONTWAIT | SendFlags::NOSIGNAL; - let iov = [IoSlice::new(bytes)]; if !fds.is_empty() { + let iov = [IoSlice::new(bytes)]; let mut cmsg_space = vec![0; rustix::cmsg_space!(ScmRights(fds.len()))]; let mut cmsg_buffer = SendAncillaryBuffer::new(&mut cmsg_space); let fds = @@ -49,8 +49,7 @@ impl Socket { cmsg_buffer.push(SendAncillaryMessage::ScmRights(fds)); Ok(sendmsg(self, &iov, &mut cmsg_buffer, flags)?) } else { - let mut cmsg_buffer = SendAncillaryBuffer::new(&mut []); - Ok(sendmsg(self, &iov, &mut cmsg_buffer, flags)?) + Ok(send(self, bytes, flags)?) } }