[Xcb-commit] src

Peter Harris peterh at kemper.freedesktop.org
Wed Aug 25 18:41:46 PDT 2010

 src/xcb_conn.c |    8 ++++++++
 1 file changed, 8 insertions(+)

New commits:
commit 7f5cfcc2fd0168d505504cc088bfdcba5c71f0ea
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Tue Aug 17 08:04:41 2010 -0700

    xcb_disconnect: call shutdown() to force a disconnect
    Fixes the X Test Suite's XCloseDisplay-6 test, which has this (admittedly
    ridiculous) behavior:
     1. Create a window w.
     2. Open two display connections, dpy1, and dpy2.
     3. Grab the server using dpy1.
     4. Fork.
     5 (child). XSetProperty on w using dpy2.
     5 (parent). Verify that no event was recieved on dpy1.
     6 (parent). XCloseDisplay(dpy1).
     6 (child). Verify that an event was received on dpy2.
    It was failing because at step 6 (child), the server had not actually ungrabbed
    yet because the file descriptor for dpy1 was still open in the child process.
    Shutting down the socket during XCloseDisplay matches the behavior of non-XCB
    Xlib, which calls shutdown() from _X11TransSocketDisconnect.
    Thanks to Julien Cristau for noticing this.
    Signed-off-by: Aaron Plattner <aplattner at nvidia.com>
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Signed-off-by: Peter Harris <pharris at opentext.com>

diff --git a/src/xcb_conn.c b/src/xcb_conn.c
index 7e18891..803f7aa 100644
--- a/src/xcb_conn.c
+++ b/src/xcb_conn.c
@@ -42,6 +42,11 @@
 #include <sys/select.h>
+/* SHUT_RDWR is fairly recent and is not available on all platforms */
+#if !defined(SHUT_RDWR)
+#define SHUT_RDWR 2
 typedef struct {
     uint8_t  status;
     uint8_t  pad0[5];
@@ -247,6 +252,9 @@ void xcb_disconnect(xcb_connection_t *c)
+    /* disallow further sends and receives */
+    shutdown(c->fd, SHUT_RDWR);

More information about the xcb-commit mailing list