[PATCH 3/3] Introduce WAYLAND_SERVER_SOCKET_DIR to change socket directory without changing XDG_RUNTIME_DIR. This might be useful to change socket directory in case wl_display_add_socket_auto is used. For example this will change the socket path for weston without using any command line argument. This envvar is ignored when WAYLAND_SERVER_SOCKET is set to an absolute path.

Marek Chalupa mchqwerty at gmail.com
Thu Mar 5 04:17:28 PST 2015


On Tue, Mar 3, 2015 at 7:49 AM, Davide Bettio <davide.bettio at ispirata.com>
wrote:

> Signed-off-by: Davide Bettio <davide.bettio at ispirata.com>
> ---
>  src/wayland-server.c | 17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/src/wayland-server.c b/src/wayland-server.c
> index 05e9c07..2922e41 100644
> --- a/src/wayland-server.c
> +++ b/src/wayland-server.c
> @@ -1093,9 +1093,12 @@ wl_socket_init_for_display_name(struct wl_socket
> *s, const char *name)
>         int name_size;
>         const char *runtime_dir;
>
> -       runtime_dir = getenv("XDG_RUNTIME_DIR");
> +       runtime_dir = getenv("WAYLAND_SERVER_SOCKET_DIR");
>         if (!runtime_dir) {
> -               wl_log("error: XDG_RUNTIME_DIR not set in the
> environment\n");
> +               runtime_dir = getenv("XDG_RUNTIME_DIR");
> +       }
> +       if (!runtime_dir) {
> +               wl_log("error: XDG_RUNTIME_DIR or
> WAYLAND_SERVER_SOCKET_DIR not set in the environment\n");
>
>
Won't this break wl_display_add_socket_auto when both variables are
defined? i. e. socket will be created in WAYLAND_SERVER_SOCKET_DIR and
wl_display_add_socket_auto returns just a name of the socket, so the client
will try to connect to XDG_RUNTIME_DIR/display_name. I suppose here is
where you use absolute paths in you setup?

I like the absolute paths and on one side I like separating WAYLAND_DISPLAY
for clients use only. On the other side if we use WAYLAND_DISPLAY for both,
client and server, we just know that both will work with the right thing
(which you don't want of course). Wouldn't absolute paths + patch for
weston (set path where to create the socket + set correct WAYLAND_DISPLAY
for childs) solve you're problem itself? When compositor is using
wl_display_add_socket it just can create it where it wants (after the first
patch of yours applied) and set right environment for clients to connect to
it. What am I missing from you're use-case?

---------------------------------------------------------------------------------------
|
weston
|
|  WAYLAND_DISPLAY=wayland-0                                    |
|
|
|
---------------------------------------------------------------------------|
|
|     | nested weston --socket-path=somewhere/socket   |     |
|     | WAYLAND_DISPLAY=somewhere/socket             |     |
|
|--------------------------------------------------------------------------|
|
|
-------------------------------------------------------------------------------------|



>                 /* to prevent programs reporting
>                  * "failed to add socket: Success" */
> @@ -1220,14 +1223,14 @@ wl_display_add_socket_auto(struct wl_display
> *display)
>   * and WAYLAND_DISPLAY env variable for the socket name. If
> WAYLAND_DISPLAY and
>   * WAYLAND_SERVER_SOCKET are not set, then default wayland-0 is used.
>   *
> - * The Unix socket will be created in the directory pointed to by
> environment
> - * variable XDG_RUNTIME_DIR. If XDG_RUNTIME_DIR is not set, then this
> function
> - * fails and returns -1.
> + * The Unix socket will be created in the directory pointed to by either
> environment
> + * variable WAYLAND_SERVER_SOCKET_DIR or XDG_RUNTIME_DIR. If the none of
> the is set,
> + * then this function  fails and returns -1.
>   *
> - * The length of socket path, i.e., the path set in XDG_RUNTIME_DIR and
> the
> + * The length of socket path, e.g., the path set in XDG_RUNTIME_DIR and
> the
>   * socket name, must not exceed the maxium length of a Unix socket path.
>   * The function also fails if the user do not have write permission in the
> - * XDG_RUNTIME_DIR path or if the socket name is already in use.
> + * wayland socket path or if the socket name is already in use.
>   *
>   * \memberof wl_display
>   */
> --
> 2.1.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/20150305/8e383f38/attachment.html>


More information about the wayland-devel mailing list