[PATCH 1/4] connection: Fix sendmsg() on BSD systems
Karsten Otto
karsten.otto at posteo.de
Sun Sep 28 11:49:02 PDT 2014
From: Philip Withnall <philip at tecnocode.co.uk>
BSD systems expect all unused fields in the msghdr struct to be
initialized to 0 and NULL respectively, and returns EINVAL otherwise.
It can't hurt to be tidy about things on other platforms either though.
[KAO: Make comments refer to all BSD-like systems]
---
src/connection.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/connection.c b/src/connection.c
index f292853..e728fd8 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -287,10 +287,16 @@ wl_connection_flush(struct wl_connection *connection)
msg.msg_namelen = 0;
msg.msg_iov = iov;
msg.msg_iovlen = count;
- msg.msg_control = cmsg;
- msg.msg_controllen = clen;
+ msg.msg_control = NULL;
+ msg.msg_controllen = 0;
msg.msg_flags = 0;
+ /* Only set msg_control when sending ancillary data */
+ if (clen > 0) {
+ msg.msg_controllen = clen;
+ msg.msg_control = cmsg;
+ }
+
do {
len = sendmsg(connection->fd, &msg,
MSG_NOSIGNAL | MSG_DONTWAIT);
--
1.9.1
More information about the wayland-devel
mailing list