[PATCH wayland 2/6] server: Create the socket FD after taking the lock

Jasper St. Pierre jstpierre at mecheye.net
Thu Jul 17 10:54:20 PDT 2014


We're going to split out the lock-taking to another function so we
can repetitively try locks.
---
 src/wayland-server.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/wayland-server.c b/src/wayland-server.c
index 3e0fb25..d919eb2 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -1082,12 +1082,6 @@ wl_display_add_socket(struct wl_display *display, const char *name)
 	if (s == NULL)
 		return -1;
 
-	s->fd = wl_os_socket_cloexec(PF_LOCAL, SOCK_STREAM, 0);
-	if (s->fd < 0) {
-		wl_socket_destroy(s);
-		return -1;
-	}
-
 	if (name == NULL)
 		name = getenv("WAYLAND_DISPLAY");
 	if (name == NULL)
@@ -1115,6 +1109,12 @@ wl_display_add_socket(struct wl_display *display, const char *name)
 		return -1;
 	}
 
+	s->fd = wl_os_socket_cloexec(PF_LOCAL, SOCK_STREAM, 0);
+	if (s->fd < 0) {
+		wl_socket_destroy(s);
+		return -1;
+	}
+
 	size = offsetof (struct sockaddr_un, sun_path) + name_size;
 	if (bind(s->fd, (struct sockaddr *) &s->addr, size) < 0) {
 		wl_log("bind() failed with error: %m\n");
-- 
2.0.1



More information about the wayland-devel mailing list