From 382f368a2795cacbe0f3690f9bf5be749f9f0f5e Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Fri, 19 Mar 2021 10:02:41 +0000 Subject: Detect FreeBSD versions with broken MSG_CMSG_CLOEXEC If we are compiling against a version of FreeBSD where MSG_CMSG_CLOEXEC does not work, use the fallback directly. This was only fixed recently (in https://cgit.freebsd.org/src/commit/?id=6ceacebdf52211). Signed-off-by: Alex Richardson --- src/wayland-os.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/wayland-os.c b/src/wayland-os.c index 44d4e72..27c6035 100644 --- a/src/wayland-os.c +++ b/src/wayland-os.c @@ -168,6 +168,15 @@ recvmsg_cloexec_fallback(int sockfd, struct msghdr *msg, int flags) ssize_t wl_os_recvmsg_cloexec(int sockfd, struct msghdr *msg, int flags) { +#if HAVE_BROKEN_MSG_CMSG_CLOEXEC + /* + * FreeBSD had a broken implementation of MSG_CMSG_CLOEXEC between 2015 + * and 2021, so we have to use the non-MSG_CMSG_CLOEXEC fallback + * directly when compiling against a version that does not include the + * fix (https://cgit.freebsd.org/src/commit/?id=6ceacebdf52211). + */ +#pragma message("Using fallback directly since MSG_CMSG_CLOEXEC is broken.") +#else ssize_t len; len = recvmsg(sockfd, msg, flags | MSG_CMSG_CLOEXEC); @@ -175,7 +184,7 @@ wl_os_recvmsg_cloexec(int sockfd, struct msghdr *msg, int flags) return len; if (errno != EINVAL) return -1; - +#endif return recvmsg_cloexec_fallback(sockfd, msg, flags); } -- cgit v1.2.3-70-g09d2