X-Git-Url: http://git.demorecorder.com/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fxcb_conn.c;h=803f7aabd2cf87d5e2f35f28638f6d81605ea96d;hb=7f5cfcc2fd0168d505504cc088bfdcba5c71f0ea;hp=50a662bb24410c711aa979bf53c925ccb92b5291;hpb=6dd8228a137d280ce24cec604a419129d8ed0e8e;p=free-sw%2Fxcb%2Flibxcb diff --git a/src/xcb_conn.c b/src/xcb_conn.c index 50a662b..803f7aa 100644 --- a/src/xcb_conn.c +++ b/src/xcb_conn.c @@ -42,6 +42,11 @@ #include #endif +/* SHUT_RDWR is fairly recent and is not available on all platforms */ +#if !defined(SHUT_RDWR) +#define SHUT_RDWR 2 +#endif + typedef struct { uint8_t status; uint8_t pad0[5]; @@ -247,6 +252,9 @@ void xcb_disconnect(xcb_connection_t *c) return; free(c->setup); + + /* disallow further sends and receives */ + shutdown(c->fd, SHUT_RDWR); close(c->fd); pthread_mutex_destroy(&c->iolock); @@ -310,15 +318,15 @@ int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vec pthread_mutex_unlock(&c->iolock); do { #if USE_POLL - ret = poll(&fd, 1, -1); + ret = poll(&fd, 1, -1); #else - ret = select(c->fd + 1, &rfds, &wfds, 0, 0); + ret = select(c->fd + 1, &rfds, &wfds, 0, 0); #endif } while (ret == -1 && errno == EINTR); - if (ret < 0) + if(ret < 0) { _xcb_conn_shutdown(c); - ret = 0; + ret = 0; } pthread_mutex_lock(&c->iolock);