[Xcb] [PATCH] xcb_disconnect: call shutdown() to force a disconnect

Barton C Massey bart at cs.pdx.edu
Mon Aug 16 12:33:01 PDT 2010


While I'm fine with this patch, I guess, we should also fix
the damn test.  We've fixed a bunch of tests like this
already IIRC...

Thanks huge for the report and fix.

	Bart

In message <20100816021928.GA8393 at soprano.nvidia.com> you wrote:
> 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>
> ---
>  src/xcb_conn.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/src/xcb_conn.c b/src/xcb_conn.c
> index 04e0430..73945c5 100644
> --- a/src/xcb_conn.c
> +++ b/src/xcb_conn.c
> @@ -247,6 +247,9 @@ void xcb_disconnect(xcb_connection_t *c)
>          return;
>  
>      free(c->setup);
> +
> +    /* disallow further sends and receives */
> +    shutdown(c->fd, 2);
>      close(c->fd);
>  
>      pthread_mutex_destroy(&c->iolock);
> -- 
> 1.7.0.4
> 
> _______________________________________________
> Xcb mailing list
> Xcb at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xcb


More information about the Xcb mailing list