X-Git-Url: http://git.demorecorder.com/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fxcb_in.c;h=fdcc813853f9f928deee4c0365ff1745d58a8351;hb=9061ee45b8dbe5431c23e3f628089d703ccad0b1;hp=4acc3a27d2dfdb2e32d87a9ecfa5e1a1467f8f83;hpb=e300ee4920bf4618f58618f3063b362f811154c1;p=free-sw%2Fxcb%2Flibxcb diff --git a/src/xcb_in.c b/src/xcb_in.c index 4acc3a2..fdcc813 100644 --- a/src/xcb_in.c +++ b/src/xcb_in.c @@ -174,7 +174,7 @@ static int read_packet(xcb_connection_t *c) (genrep.response_type == XCB_REPLY ? 0 : sizeof(uint32_t))); if(!buf) { - _xcb_conn_shutdown(c); + _xcb_conn_shutdown(c, XCB_CONN_CLOSED_MEM_INSUFFICIENT); return 0; } @@ -210,7 +210,7 @@ static int read_packet(xcb_connection_t *c) struct reply_list *cur = malloc(sizeof(struct reply_list)); if(!cur) { - _xcb_conn_shutdown(c); + _xcb_conn_shutdown(c, XCB_CONN_CLOSED_MEM_INSUFFICIENT); free(buf); return 0; } @@ -227,7 +227,7 @@ static int read_packet(xcb_connection_t *c) event = malloc(sizeof(struct event_list)); if(!event) { - _xcb_conn_shutdown(c); + _xcb_conn_shutdown(c, XCB_CONN_CLOSED_MEM_INSUFFICIENT); free(buf); return 0; } @@ -269,7 +269,11 @@ static int read_block(const int fd, void *buf, const ssize_t len) int done = 0; while(done < len) { +#ifdef __APPLE__ + int ret = read(fd, ((char *) buf) + done, len - done); +#else int ret = recv(fd, ((char *) buf) + done, len - done,MSG_WAITALL); +#endif if(ret > 0) done += ret; #ifndef _WIN32 @@ -433,7 +437,7 @@ static void insert_pending_discard(xcb_connection_t *c, pending_reply **prev_nex pend = malloc(sizeof(*pend)); if(!pend) { - _xcb_conn_shutdown(c); + _xcb_conn_shutdown(c, XCB_CONN_CLOSED_MEM_INSUFFICIENT); return; } @@ -535,7 +539,7 @@ static xcb_generic_event_t *poll_for_next_event(xcb_connection_t *c, int queued) pthread_mutex_lock(&c->iolock); /* FIXME: follow X meets Z architecture changes. */ ret = get_event(c); - if(!ret && !queued && _xcb_in_read(c)) /* _xcb_in_read shuts down the connection on error */ + if(!ret && !queued && c->in.reading == 0 && _xcb_in_read(c)) /* _xcb_in_read shuts down the connection on error */ ret = get_event(c); pthread_mutex_unlock(&c->iolock); } @@ -633,7 +637,7 @@ int _xcb_in_expect_reply(xcb_connection_t *c, uint64_t request, enum workarounds assert(workaround != WORKAROUND_NONE || flags != 0); if(!pend) { - _xcb_conn_shutdown(c); + _xcb_conn_shutdown(c, XCB_CONN_CLOSED_MEM_INSUFFICIENT); return 0; } pend->first_request = pend->last_request = request; @@ -661,7 +665,11 @@ void _xcb_in_replies_done(xcb_connection_t *c) int _xcb_in_read(xcb_connection_t *c) { +#ifdef __APPLE__ + int n = read(c->fd, c->in.queue + c->in.queue_len, sizeof(c->in.queue) - c->in.queue_len); +#else int n = recv(c->fd, c->in.queue + c->in.queue_len, sizeof(c->in.queue) - c->in.queue_len,MSG_WAITALL); +#endif if(n > 0) c->in.queue_len += n; while(read_packet(c)) @@ -672,7 +680,7 @@ int _xcb_in_read(xcb_connection_t *c) if((n > 0) || (n < 0 && WSAGetLastError() == WSAEWOULDBLOCK)) #endif /* !_WIN32 */ return 1; - _xcb_conn_shutdown(c); + _xcb_conn_shutdown(c, XCB_CONN_ERROR); return 0; } @@ -691,7 +699,7 @@ int _xcb_in_read_block(xcb_connection_t *c, void *buf, int len) int ret = read_block(c->fd, (char *) buf + done, len - done); if(ret <= 0) { - _xcb_conn_shutdown(c); + _xcb_conn_shutdown(c, XCB_CONN_ERROR); return ret; } }