[PATCH] Fall back to accept() on systems where accept4() is not implemented.

Samuel Rødal samuel.rodal at nokia.com
Mon May 30 08:23:40 PDT 2011


---
 wayland/wayland-server.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/wayland/wayland-server.c b/wayland/wayland-server.c
index d30df5b..886ec69 100644
--- a/wayland/wayland-server.c
+++ b/wayland/wayland-server.c
@@ -703,8 +703,14 @@ socket_data(int fd, uint32_t mask, void *data)
 	length = sizeof name;
 	client_fd =
 		accept4(fd, (struct sockaddr *) &name, &length, SOCK_CLOEXEC);
+	if (client_fd < 0 && errno == ENOSYS) {
+		client_fd = accept(fd, (struct sockaddr *) &name, &length);
+		if (client_fd >= 0 && fcntl(client_fd, F_SETFD, FD_CLOEXEC) == -1)
+			fprintf(stderr, "failed to set FD_CLOEXEC flag on client fd, errno: %d\n", errno);
+	}
+
 	if (client_fd < 0)
-		fprintf(stderr, "failed to accept\n");
+		fprintf(stderr, "failed to accept, errno: %d\n", errno);
 
 	wl_client_create(display, client_fd);
 
-- 
1.7.1


--------------060306070106060207060006--


More information about the wayland-devel mailing list