projects
/
free-sw
/
xcb
/
libxcb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added more error states and removed global error_connection
[free-sw/xcb/libxcb]
/
src
/
xcb_in.c
diff --git
a/src/xcb_in.c
b/src/xcb_in.c
index
1199e23
..
969cfc0
100644
(file)
--- a/
src/xcb_in.c
+++ b/
src/xcb_in.c
@@
-167,14
+167,14
@@
static int read_packet(xcb_connection_t *c)
}
/* XGE events may have sizes > 32 */
}
/* XGE events may have sizes > 32 */
- if (
genrep.response_type
== XCB_XGE_EVENT)
+ if (
(genrep.response_type & 0x7f)
== XCB_XGE_EVENT)
eventlength = genrep.length * 4;
buf = malloc(length + eventlength +
(genrep.response_type == XCB_REPLY ? 0 : sizeof(uint32_t)));
if(!buf)
{
eventlength = genrep.length * 4;
buf = malloc(length + eventlength +
(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;
}
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)
{
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;
}
free(buf);
return 0;
}
@@
-227,7
+227,7
@@
static int read_packet(xcb_connection_t *c)
event = malloc(sizeof(struct event_list));
if(!event)
{
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;
}
free(buf);
return 0;
}
@@
-433,7
+433,7
@@
static void insert_pending_discard(xcb_connection_t *c, pending_reply **prev_nex
pend = malloc(sizeof(*pend));
if(!pend)
{
pend = malloc(sizeof(*pend));
if(!pend)
{
- _xcb_conn_shutdown(c);
+ _xcb_conn_shutdown(c
, XCB_CONN_CLOSED_MEM_INSUFFICIENT
);
return;
}
return;
}
@@
-527,7
+527,7
@@
xcb_generic_event_t *xcb_wait_for_event(xcb_connection_t *c)
return ret;
}
return ret;
}
-
xcb_generic_event_t *xcb_poll_for_event(xcb_connection_t *c
)
+
static xcb_generic_event_t *poll_for_next_event(xcb_connection_t *c, int queued
)
{
xcb_generic_event_t *ret = 0;
if(!c->has_error)
{
xcb_generic_event_t *ret = 0;
if(!c->has_error)
@@
-535,13
+535,23
@@
xcb_generic_event_t *xcb_poll_for_event(xcb_connection_t *c)
pthread_mutex_lock(&c->iolock);
/* FIXME: follow X meets Z architecture changes. */
ret = get_event(c);
pthread_mutex_lock(&c->iolock);
/* FIXME: follow X meets Z architecture changes. */
ret = get_event(c);
- if(!ret && _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);
}
return ret;
}
ret = get_event(c);
pthread_mutex_unlock(&c->iolock);
}
return ret;
}
+xcb_generic_event_t *xcb_poll_for_event(xcb_connection_t *c)
+{
+ return poll_for_next_event(c, 0);
+}
+
+xcb_generic_event_t *xcb_poll_for_queued_event(xcb_connection_t *c)
+{
+ return poll_for_next_event(c, 1);
+}
+
xcb_generic_error_t *xcb_request_check(xcb_connection_t *c, xcb_void_cookie_t cookie)
{
uint64_t request;
xcb_generic_error_t *xcb_request_check(xcb_connection_t *c, xcb_void_cookie_t cookie)
{
uint64_t request;
@@
-623,7
+633,7
@@
int _xcb_in_expect_reply(xcb_connection_t *c, uint64_t request, enum workarounds
assert(workaround != WORKAROUND_NONE || flags != 0);
if(!pend)
{
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;
return 0;
}
pend->first_request = pend->last_request = request;
@@
-662,7
+672,7
@@
int _xcb_in_read(xcb_connection_t *c)
if((n > 0) || (n < 0 && WSAGetLastError() == WSAEWOULDBLOCK))
#endif /* !_WIN32 */
return 1;
if((n > 0) || (n < 0 && WSAGetLastError() == WSAEWOULDBLOCK))
#endif /* !_WIN32 */
return 1;
- _xcb_conn_shutdown(c);
+ _xcb_conn_shutdown(c
, XCB_CONN_ERROR
);
return 0;
}
return 0;
}
@@
-681,7
+691,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)
{
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;
}
}
return ret;
}
}