[PATCH wayland 1/3] server: Create the socket FD after taking the lock

Jason Ekstrand jason at jlekstrand.net
Wed May 7 18:11:00 PDT 2014


Yeah, this looks good to me.  It does change the order of a couple of
system calls, but it looks ok to me.

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>


On Wed, May 7, 2014 at 9:25 AM, Jasper St. Pierre <jstpierre at mecheye.net>wrote:

> ---
>  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
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20140507/a4bd2dc1/attachment-0001.html>


More information about the wayland-devel mailing list