[Xcb] [PATCH] Check for unexpected poll() events in _xcb_conn_wait.

Aaron Plattner aplattner at nvidia.com
Sun Jul 11 11:29:37 PDT 2010


Fixes the XTS XConnectionNumber test.
http://cgit.freedesktop.org/xorg/test/xts/tree/xts5/Xlib3/XConnectionNumber.m

This test creates a display connection, closes its file descriptor, tries to
send a no-op, and then expects an error.  XCB just goes into an infinite loop
because poll() returns immediately with POLLNVAL set.

Signed-off-by: Aaron Plattner <aplattner at nvidia.com>
---
> Thanks Aaron! A different patch was recently submitted for
> this, but I think perhaps I like yours better. It's a bit
> simpler.

D'oh.  Sorry!

> Would it make sense to test whether fd.revents contains
> ~(POLLIN|POLLOUT) instead?

That's a good idea.  I used ~fd.events instead, in case
anyone adds something to it later.  How does this look?


 src/xcb_conn.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/xcb_conn.c b/src/xcb_conn.c
index 50a662b..d8a3a31 100644
--- a/src/xcb_conn.c
+++ b/src/xcb_conn.c
@@ -315,6 +315,13 @@ int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vec
 	ret = select(c->fd + 1, &rfds, &wfds, 0, 0);
 #endif
     } while (ret == -1 && errno == EINTR);
+#if USE_POLL
+    /* If poll() returns an event we didn't expect, such as POLLNVAL, treat it
+     * as if it failed. */
+    if (ret >= 0 && (fd.revents & ~fd.events)) {
+        ret = -1;
+    }
+#endif
     if (ret < 0)
     {
         _xcb_conn_shutdown(c);
-- 
1.7.0.4



More information about the Xcb mailing list