summaryrefslogtreecommitdiff
path: root/dist/libxcb/src
diff options
context:
space:
mode:
authorDavid Coppa <dcoppa@cvs.openbsd.org>2010-10-06 07:50:07 +0000
committerDavid Coppa <dcoppa@cvs.openbsd.org>2010-10-06 07:50:07 +0000
commitfaa4393fa53bec309196272c36ac5b85f0ef10ba (patch)
tree9070772becd018799b9a44d80fe2586242ba3644 /dist/libxcb/src
parent4b00205867685f1e9f409937e03a9ff65dab26ab (diff)
Bugfixes from upstream.
Minor tweaks (shutdown(2) related bits) by me. OK matthieu@
Diffstat (limited to 'dist/libxcb/src')
-rw-r--r--dist/libxcb/src/xcb_conn.c16
-rw-r--r--dist/libxcb/src/xcb_in.c2
-rw-r--r--dist/libxcb/src/xcb_util.c2
-rw-r--r--dist/libxcb/src/xcbint.h2
4 files changed, 17 insertions, 5 deletions
diff --git a/dist/libxcb/src/xcb_conn.c b/dist/libxcb/src/xcb_conn.c
index 7e18891a1..8cd7b00ea 100644
--- a/dist/libxcb/src/xcb_conn.c
+++ b/dist/libxcb/src/xcb_conn.c
@@ -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 fd, xcb_auth_info_t *auth_info)
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, pthread_cond_t *cond, struct iovec **vec
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
diff --git a/dist/libxcb/src/xcb_in.c b/dist/libxcb/src/xcb_in.c
index 6dd358cbd..5a87466f3 100644
--- a/dist/libxcb/src/xcb_in.c
+++ b/dist/libxcb/src/xcb_in.c
@@ -564,7 +564,7 @@ xcb_generic_error_t *xcb_request_check(xcb_connection_t *c, xcb_void_cookie_t co
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));
diff --git a/dist/libxcb/src/xcb_util.c b/dist/libxcb/src/xcb_util.c
index 5a82ac129..07fa4a38e 100644
--- a/dist/libxcb/src/xcb_util.c
+++ b/dist/libxcb/src/xcb_util.c
@@ -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;
diff --git a/dist/libxcb/src/xcbint.h b/dist/libxcb/src/xcbint.h
index f07add8b9..69912389c 100644
--- a/dist/libxcb/src/xcbint.h
+++ b/dist/libxcb/src/xcbint.h
@@ -174,6 +174,8 @@ void _xcb_ext_destroy(xcb_connection_t *c);
/* xcb_conn.c */
+extern const int error_connection;
+
struct xcb_connection_t {
int has_error;