From: Peter Harris Date: Thu, 23 Dec 2010 18:04:40 +0000 (-0500) Subject: Merge branch 'master' of git://anongit.freedesktop.org/~peterh/libxcb X-Git-Url: http://git.demorecorder.com/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c5813697169a33ecfd6ac0ab5641dec654f6612;hp=b672d1514c88e119f3aaeded8c8a488cad36db52;p=free-sw%2Fxcb%2Flibxcb Merge branch 'master' of git://anongit.freedesktop.org/~peterh/libxcb --- diff --git a/src/xcb_auth.c b/src/xcb_auth.c index 1af27fc..4839b78 100644 --- a/src/xcb_auth.c +++ b/src/xcb_auth.c @@ -327,10 +327,15 @@ int _xcb_get_auth_info(int fd, xcb_auth_info_t *info, int display) if (!info->namelen) goto no_auth; /* out of memory */ - if (!gotsockname && (sockname = get_peer_sock_name(getsockname, fd)) == NULL) + if (!gotsockname) { - free(info->name); - goto no_auth; /* can only authenticate sockets */ + free(sockname); + + if ((sockname = get_peer_sock_name(getsockname, fd)) == NULL) + { + free(info->name); + goto no_auth; /* can only authenticate sockets */ + } } ret = compute_auth(info, authptr, sockname); diff --git a/src/xcb_conn.c b/src/xcb_conn.c index f2a2636..a017c20 100644 --- a/src/xcb_conn.c +++ b/src/xcb_conn.c @@ -58,7 +58,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) { @@ -257,6 +257,7 @@ xcb_connection_t *xcb_connect_to_fd(int fd, xcb_auth_info_t *auth_info) { xcb_connection_t* c; +#ifndef _WIN32 #ifndef USE_POLL if(fd >= FD_SETSIZE) /* would overflow in FD_SET */ { @@ -264,6 +265,7 @@ xcb_connection_t *xcb_connect_to_fd(int fd, xcb_auth_info_t *auth_info) return (xcb_connection_t *) &error_connection; } #endif +#endif /* !_WIN32*/ c = calloc(1, sizeof(xcb_connection_t)); if(!c) { @@ -293,7 +295,7 @@ 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); diff --git a/src/xcb_util.c b/src/xcb_util.c index c14d9d5..223dcaf 100644 --- a/src/xcb_util.c +++ b/src/xcb_util.c @@ -54,8 +54,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/src/xcbext.h b/src/xcbext.h index eb69538..98b3c93 100644 --- a/src/xcbext.h +++ b/src/xcbext.h @@ -65,15 +65,22 @@ unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vect * request XCB sent. The caller of xcb_take_socket must supply a * callback which XCB can call when it wants the write side of the * socket back to make a request. This callback synchronizes with the - * external socket owner, flushes any output queues if appropriate, and - * then returns the sequence number of the last request sent over the - * socket. */ + * external socket owner and flushes any output queues if appropriate. + * If you are sending requests which won't cause a reply, please note the + * comment for xcb_writev which explains some sequence number wrap issues. + * */ int xcb_take_socket(xcb_connection_t *c, void (*return_socket)(void *closure), void *closure, int flags, uint64_t *sent); /* You must own the write-side of the socket (you've called * xcb_take_socket, and haven't returned from return_socket yet) to call * xcb_writev. Also, the iovec must have at least 1 byte of data in it. - * */ + * You have to make sure that xcb can detect sequence number wraps correctly. + * This means that the first request you send after xcb_take_socket must cause a + * reply (e.g. just insert a GetInputFocus request). After every (1 << 16) - 1 + * requests without a reply, you have to insert a request which will cause a + * reply. You can again use GetInputFocus for this. You do not have to wait for + * any of the GetInputFocus replies, but can instead handle them via + * xcb_discard_reply(). */ int xcb_writev(xcb_connection_t *c, struct iovec *vector, int count, uint64_t requests); diff --git a/src/xcbint.h b/src/xcbint.h index f07add8..6991238 100644 --- a/src/xcbint.h +++ b/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;