Hi, 
the usual fixes for libxcb...

These include the fixes from upstream plus minor nits by me for 
the shutdown(2) syscall on OpenBSD (missing includes).

cheers, 
david

Index: src/xcb_conn.c
===================================================================
RCS file: /cvs/xenocara/dist/libxcb/src/xcb_conn.c,v
retrieving revision 1.4
diff -u -p -r1.4 xcb_conn.c
--- src/xcb_conn.c      4 Sep 2010 10:00:58 -0000       1.4
+++ src/xcb_conn.c      4 Oct 2010 09:01:40 -0000
@@ -26,6 +26,8 @@
 /* Connection management: the core of XCB. */
 
 #include <assert.h>
+#include <sys/types.h>
+#include <sys/socket.h>
 #include <string.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -48,7 +50,7 @@ typedef struct {
     uint16_t length;
 } xcb_setup_generic_t;
 
-static const int error_connection = 1;
+const int error_connection = 1;
 
 static int set_fd_flags(const int fd)
 {
@@ -243,10 +245,13 @@ xcb_connection_t *xcb_connect_to_fd(int 
 
 void xcb_disconnect(xcb_connection_t *c)
 {
-    if(c->has_error)
+    if(c == (xcb_connection_t *) &error_connection)
         return;
 
     free(c->setup);
+
+    /* disallow further sends and receives */
+    shutdown(c->fd, SHUT_RDWR);
     close(c->fd);
 
     pthread_mutex_destroy(&c->iolock);
@@ -311,6 +316,13 @@ int _xcb_conn_wait(xcb_connection_t *c, 
     do {
 #if USE_POLL
         ret = poll(&fd, 1, -1);
+        /* 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;
+            break;
+        }
 #else
         ret = select(c->fd + 1, &rfds, &wfds, 0, 0);
 #endif
Index: src/xcb_in.c
===================================================================
RCS file: /cvs/xenocara/dist/libxcb/src/xcb_in.c,v
retrieving revision 1.4
diff -u -p -r1.4 xcb_in.c
--- src/xcb_in.c        4 Sep 2010 10:00:59 -0000       1.4
+++ src/xcb_in.c        4 Oct 2010 09:01:40 -0000
@@ -564,7 +564,7 @@ xcb_generic_error_t *xcb_request_check(x
     void *reply;
     if(c->has_error)
         return 0;
-    if(XCB_SEQUENCE_COMPARE_32(cookie.sequence,>,c->in.request_expected)
+    if(XCB_SEQUENCE_COMPARE_32(cookie.sequence,>=,c->in.request_expected)
        && XCB_SEQUENCE_COMPARE_32(cookie.sequence,>,c->in.request_completed))
     {
         free(xcb_get_input_focus_reply(c, xcb_get_input_focus(c), &ret));
Index: src/xcb_util.c
===================================================================
RCS file: /cvs/xenocara/dist/libxcb/src/xcb_util.c,v
retrieving revision 1.5
diff -u -p -r1.5 xcb_util.c
--- src/xcb_util.c      4 Sep 2010 10:00:59 -0000       1.5
+++ src/xcb_util.c      4 Oct 2010 09:01:42 -0000
@@ -49,8 +49,6 @@
 #include "xcbext.h"
 #include "xcbint.h"
 
-static const int error_connection = 1;
-
 int xcb_popcount(uint32_t mask)
 {
     uint32_t y;
Index: src/xcbint.h
===================================================================
RCS file: /cvs/xenocara/dist/libxcb/src/xcbint.h,v
retrieving revision 1.3
diff -u -p -r1.3 xcbint.h
--- src/xcbint.h        4 Sep 2010 10:00:59 -0000       1.3
+++ src/xcbint.h        4 Oct 2010 09:01:42 -0000
@@ -174,6 +174,8 @@ void _xcb_ext_destroy(xcb_connection_t *
 
 /* xcb_conn.c */
 
+extern const int error_connection;
+
 struct xcb_connection_t {
     int has_error;

Reply via email to