[PATCH wayland 1/3] server: Create the socket FD after taking the lock
Jasper St. Pierre
jstpierre at mecheye.net
Wed May 7 07:25:28 PDT 2014
---
src/wayland-server.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/src/wayland-server.c b/src/wayland-server.c
index e850d48..d0fd280 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -1061,12 +1061,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) {
- free(s);
- return -1;
- }
-
if (name == NULL)
name = getenv("WAYLAND_DISPLAY");
if (name == NULL)
@@ -1081,7 +1075,6 @@ wl_display_add_socket(struct wl_display *display, const char *name)
if (name_size > (int)sizeof s->addr.sun_path) {
wl_log("error: socket path \"%s/%s\" plus null terminator"
" exceeds 108 bytes\n", runtime_dir, name);
- close(s->fd);
free(s);
/* to prevent programs reporting
* "failed to add socket: Success" */
@@ -1091,7 +1084,13 @@ wl_display_add_socket(struct wl_display *display, const char *name)
s->fd_lock = get_socket_lock(s);
if (s->fd_lock < 0) {
- close(s->fd);
+ free(s);
+ return -1;
+ }
+
+ s->fd = wl_os_socket_cloexec(PF_LOCAL, SOCK_STREAM, 0);
+ if (s->fd < 0) {
+ close(s->fd_lock);
free(s);
return -1;
}
--
1.9.0
More information about the wayland-devel
mailing list