libxcb/libxcb-1.1-abstract-socket.patch
2007-11-12 15:36:24 +00:00

28 lines
844 B
Diff

diff -up libxcb-1.1/src/xcb_util.c.abstract libxcb-1.1/src/xcb_util.c
--- libxcb-1.1/src/xcb_util.c.abstract 2007-10-23 12:44:59.000000000 -0400
+++ libxcb-1.1/src/xcb_util.c 2007-11-12 10:32:37.000000000 -0500
@@ -249,13 +249,22 @@ static int _xcb_open_unix(char *protocol
if (protocol && strcmp("unix",protocol))
return -1;
- strcpy(addr.sun_path, file);
+ memset(&addr, 0, sizeof(addr));
+ addr.sun_family = AF_UNIX;
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if(fd == -1)
return -1;
+
+ /* try the abstract socket first */
+ strcpy(addr.sun_path + 1, file);
+ if(connect(fd, (struct sockaddr *) &addr, sizeof(addr)) != -1)
+ return fd;
+
+ strcpy(addr.sun_path, file);
if(connect(fd, (struct sockaddr *) &addr, sizeof(addr)) == -1)
return -1;
+
return fd;
}