diff --git a/src/xcb_conn.c b/src/xcb_conn.c index 7979491..8be1849 100644 --- a/src/xcb_conn.c +++ b/src/xcb_conn.c @@ -286,6 +286,7 @@ xcb_connection_t *xcb_connect_to_fd(int fd, xcb_auth_info_t *auth_info) if(!( set_fd_flags(fd) && pthread_mutex_init(&c->iolock, 0) == 0 && + pthread_mutex_init(&c->pllock, 0) == 0 && _xcb_in_init(&c->in) && _xcb_out_init(&c->out) && write_setup(c, auth_info) && @@ -313,6 +314,7 @@ void xcb_disconnect(xcb_connection_t *c) close(c->fd); pthread_mutex_destroy(&c->iolock); + pthread_mutex_destroy(&c->pllock); _xcb_in_destroy(&c->in); _xcb_out_destroy(&c->out); @@ -405,18 +407,21 @@ int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vec pthread_mutex_unlock(&c->iolock); do { + pthread_mutex_lock(&c->pllock); #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)) { + pthread_mutex_unlock(&c->pllock); ret = -1; break; } #else ret = select(c->fd + 1, &rfds, &wfds, 0, 0); #endif + pthread_mutex_unlock(&c->pllock); } while (ret == -1 && errno == EINTR); if(ret < 0) { diff --git a/src/xcbint.h b/src/xcbint.h index f9e5a52..55fb296 100644 --- a/src/xcbint.h +++ b/src/xcbint.h @@ -183,6 +183,7 @@ struct xcb_connection_t { /* I/O data */ pthread_mutex_t iolock; + pthread_mutex_t pllock; _xcb_in in; _xcb_out out;