[Xcb] [PATCH] Terminate the connection if the fd was closed on us.

Dan Nicholson dbn.lists at gmail.com
Tue Jul 6 06:03:12 PDT 2010

On Sun, Jul 4, 2010 at 5:54 PM, Peter Hutterer <peter.hutterer at who-t.net> wrote:
> If a client calls close(2) on the connection's file descriptor and then
> XFlush(3), libxcb causes a hang in the client.
> XFlush(3) eventually calls _xcb_out_send() with has the following loop:
>    while(ret && *count)
>        ret = _xcb_conn_wait(c, &c->out.cond, vector, count);
> _xcb_conn_wait(), if built with USE_POLL gets the POLLNVAL error. It only
> checks for POLLIN and POLLOUT though, ignoring the error.  Return value is
> 1, count is unmodified, leaving us with an endless loop and the a client
> hang.
> This patch adds a check for POLLNVAL in the polling code. If POLLNVAL is
> detected, _xcb_conn_shutdown() is invoked an and error is returned. This
> matches the behaviour if select(2) is used instead of poll(2). select(2)
> returns -1 and EBADF for an already closed file descriptor.
> Fixes XTS testcase Xlib3/XConnectionNumber.
> http://cgit.freedesktop.org/xorg/test/xts/tree/xts5/Xlib3/XConnectionNumber.m
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

It fixes the XConnectionNumber test for me. Nice job, Peter.

Tested-by: Dan Nicholson <dbn.lists at gmail.com>

More information about the Xcb mailing list