[PATCH 01/12] connection: Fix sendmsg() on FreeBSD

Philip Withnall philip at tecnocode.co.uk
Fri Feb 15 04:56:16 PST 2013


It expects ((msg_controllen == 0) == (msg_control == NULL)), and returns
EINVAL otherwise. It can’t hurt to be tidy about things on other platforms
either though.

See: http://www.freebsd.org/cgi/query-pr.cgi?pr=docs/99356#reply2

Signed-off-by: Philip Withnall <philip at tecnocode.co.uk>
---
 src/connection.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/connection.c b/src/connection.c
index 8707d40..1e00443 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -284,10 +284,19 @@ 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;
 
+		/* FreeBSD requires msg_control to be set to NULL iff
+		 * msg_controllen is 0 (see
+		 * http://www.freebsd.org/cgi/query-pr.cgi?pr=docs/99356#reply2)
+		 * Can't hurt to do that on all platforms. */
+		if (clen > 0) {
+			msg.msg_controllen = clen;
+			msg.msg_control = cmsg;
+		}
+
 		do {
 			len = sendmsg(connection->fd, &msg,
 				      MSG_NOSIGNAL | MSG_DONTWAIT);
-- 
1.7.11.7

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 230 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20130215/c8008e68/attachment-0001.pgp>


More information about the wayland-devel mailing list