<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 3, 2015 at 7:49 AM, Davide Bettio <span dir="ltr"><<a href="mailto:davide.bettio@ispirata.com" target="_blank">davide.bettio@ispirata.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Signed-off-by: Davide Bettio <<a href="mailto:davide.bettio@ispirata.com" target="_blank">davide.bettio@ispirata.com</a>><br>
---<br>
 doc/man/wl_display_connect.xml |  8 ++++----<br>
 src/wayland-client.c           | 22 +++++++++++++++++-----<br>
 src/wayland-server.c           | 23 ++++++++++++++++++-----<br>
 3 files changed, 39 insertions(+), 14 deletions(-)<br>
<br>
diff --git a/doc/man/wl_display_connect.xml b/doc/man/wl_display_connect.xml<br>
index 7e6e05c..b78c53f 100644<br>
--- a/doc/man/wl_display_connect.xml<br>
+++ b/doc/man/wl_display_connect.xml<br>
@@ -59,10 +59,10 @@<br>
           find it. The <varname>name</varname> argument specifies the name of<br>
           the socket or <constant>NULL</constant> to use the default (which is<br>
           <constant>"wayland-0"</constant>). The environment variable<br>
-          <envar>WAYLAND_DISPLAY</envar> replaces the default value. If<br>
-          <envar>WAYLAND_SOCKET</envar> is set, this function behaves like<br>
-          <function>wl_display_connect_to_fd</function> with the file-descriptor<br>
-          number taken from the environment variable.</para><br>
+          <envar>WAYLAND_DISPLAY</envar> replaces the default value, and eventually uses<br>
+          a different path too. If <envar>WAYLAND_SOCKET</envar> is set, this function<br>
+          behaves like <function>wl_display_connect_to_fd</function> with the<br>
+          file-descriptor number taken from the environment variable.</para><br>
<br>
     <para><function>wl_display_connect_to_fd</function> connects to a Wayland<br>
           socket with an explicit file-descriptor. The file-descriptor is passed<br>
diff --git a/src/wayland-client.c b/src/wayland-client.c<br>
index 0f1405c..cc01573 100644<br>
--- a/src/wayland-client.c<br>
+++ b/src/wayland-client.c<br>
@@ -768,14 +768,26 @@ connect_to_socket(const char *name)<br>
<br>
        memset(&addr, 0, sizeof addr);<br>
        addr.sun_family = AF_LOCAL;<br>
-       name_size =<br>
-               snprintf(addr.sun_path, sizeof addr.sun_path,<br>
-                        "%s/%s", runtime_dir, name) + 1;<br>
+       if (name[0] != '/') {<br>
+               name_size =<br>
+                       snprintf(addr.sun_path, sizeof addr.sun_path,<br>
+                                "%s/%s", runtime_dir, name) + 1;<br>
+       } else {<br>
+               /* absolute path */<br>
+               name_size =<br>
+                       snprintf(addr.sun_path, sizeof addr.sun_path,<br>
+                                "%s", name) + 1;<br>
+       }<br>
<br>
        assert(name_size > 0);<br>
        if (name_size > (int)sizeof addr.sun_path) {<br>
-               wl_log("error: socket path \"%s/%s\" plus null terminator"<br>
-                      " exceeds 108 bytes\n", runtime_dir, name);<br>
+               if (name[0] != '/') {<br>
+                       wl_log("error: socket path \"%s/%s\" plus null terminator"<br>
+                              " exceeds 108 bytes\n", runtime_dir, name);<br>
+               } else {<br>
+                       wl_log("error: socket path \"%s\" plus null terminator"<br>
+                              " exceeds 108 bytes\n", name);<br>
+               }<br>
                close(fd);<br>
                /* to prevent programs reporting<br>
                 * "failed to add socket: Success" */<br>
diff --git a/src/wayland-server.c b/src/wayland-server.c<br>
index 0558634..eefbe35 100644<br>
--- a/src/wayland-server.c<br>
+++ b/src/wayland-server.c<br>
@@ -1104,15 +1104,28 @@ wl_socket_init_for_display_name(struct wl_socket *s, const char *name)<br>
        }<br>
<br></blockquote><div><br></div><div>Before the following piece of code is check for XDG_RUNTIME_DIR env variable and if it is not set,<br></div><div>the function returns here (<a href="http://cgit.freedesktop.org/wayland/wayland/tree/src/wayland-server.c#n1097" target="_blank">http://cgit.freedesktop.org/wayland/wayland/tree/src/wayland-server.c#n1097</a>).<br>When absolute path is given, we don't need XDG_RUNTIME_DIR specified, so you'd probably want to take care of it.<br></div><div>The same is in wayland-client.c.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
        s->addr.sun_family = AF_LOCAL;<br>
-       name_size = snprintf(s->addr.sun_path, sizeof s->addr.sun_path,<br>
-                            "%s/%s", runtime_dir, name) + 1;<br>
+       if (name[0] != '/') {<br>
+               name_size = snprintf(s->addr.sun_path, sizeof s->addr.sun_path,<br>
+                                    "%s/%s", runtime_dir, name) + 1;<br>
<br>
-       s->display_name = (s->addr.sun_path + name_size - 1) - strlen(name);<br>
+               s->display_name = (s->addr.sun_path + name_size - 1) - strlen(name);<br>
+       } else {<br>
+               //absolute path<br></blockquote><div> </div><div>use original C comments, please<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+               name_size = snprintf(s->addr.sun_path, sizeof s->addr.sun_path,<br>
+                                    "%s", name) + 1;<br>
+<br>
+               s->display_name = strrchr(s->addr.sun_path, '/') + 1; <br></blockquote><div><br></div><div>I wonder if this is right. Until now, when you had display_name,<br>you knew that the socket was $XDG_RUNTIME_DIR/display_name.<br>Now it can be anywhere and you still have just name of it. However, this does not look like a big deal since<br></div><div>s->display_name is used only in wl_display_add_socket_auto where we use our own names.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+       }<br>
<br>
        assert(name_size > 0);<br>
        if (name_size > (int)sizeof s->addr.sun_path) {<br>
-               wl_log("error: socket path \"%s/%s\" plus null terminator"<br>
-                      " exceeds 108 bytes\n", runtime_dir, name);<br>
+               if (name[0] != '/') {<br>
+                       wl_log("error: socket path \"%s/%s\" plus null terminator"<br>
+                               " exceeds 108 bytes\n", runtime_dir, name);<br>
+               } else {<br>
+                       wl_log("error: socket path \"%s\" plus null terminator"<br>
+                              " exceeds 108 bytes\n", name);<br>
+               }<br>
                *s->addr.sun_path = 0;<br>
                /* to prevent programs reporting<br>
                 * "failed to add socket: Success" */<br>
<span><font color="#888888">--<br>
2.1.0<br>
<br>
_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org" target="_blank">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br></font></span></blockquote><div><br></div><div>Any tests for this patch?<br><br></div><div>Best Regards,<br></div><div>Marek <br></div></div><br></div></div>