diff options
author | Jamey Sharp <jamey@minilop.net> | 2006-09-21 12:13:37 -0700 |
---|---|---|
committer | Jamey Sharp <jamey@minilop.net> | 2006-09-21 15:05:01 -0700 |
commit | df7fb77d6e22be76ca73f111c586db99a60178ae (patch) | |
tree | 482fe0c23d268405551cbff9fa0a2519250558d4 | |
parent | b08ca2b4b451a94ece20207766cd5262fd55179b (diff) |
Refactor XCBPollForEvent with a shorter critical section.
This simplifies the patch for bug #8208 later.
-rw-r--r-- | src/xcb_in.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/xcb_in.c b/src/xcb_in.c index d4dbb3f..eab8b1d 100644 --- a/src/xcb_in.c +++ b/src/xcb_in.c @@ -380,21 +380,27 @@ XCBGenericEvent *XCBWaitForEvent(XCBConnection *c) XCBGenericEvent *XCBPollForEvent(XCBConnection *c, int *error) { XCBGenericEvent *ret = 0; + int success; pthread_mutex_lock(&c->iolock); - if(error) - *error = 0; /* FIXME: follow X meets Z architecture changes. */ - if(_xcb_in_read(c)) + success = _xcb_in_read(c); + if(success) ret = get_event(c); - else if(error) + pthread_mutex_unlock(&c->iolock); + if(success) + { + if(error) + *error = 0; + return ret; + } + if(error) *error = -1; else { fprintf(stderr, "XCBPollForEvent: I/O error occured, but no handler provided.\n"); abort(); } - pthread_mutex_unlock(&c->iolock); - return ret; + return 0; } XCBGenericError *XCBRequestCheck(XCBConnection *c, XCBVoidCookie cookie) |