diff options
author | Christian Linhart <chris@demorecorder.com> | 2015-04-29 09:11:37 +0200 |
---|---|---|
committer | Christian Linhart <chris@demorecorder.com> | 2015-04-08 11:55:48 +0200 |
commit | cb621341a62e6d2233db3e337611f6fdd4f675a6 (patch) | |
tree | f50f034344e974fa95fe72274290abb8a5b3bbfd /src/xcb_in.c | |
parent | c49aa985941112be05599032b9bb45b2652301ce (diff) |
expose 64-bit sequence numbers for XLib
While XCB uses 64-bit sequence number internally, it only exposes
"unsigned int" so that, on 32-bit architecture, Xlib based applications
may see their sequence number wrap which causes the connection to the X
server to be lost.
Expose 64-bit sequence number from XCB API so that Xlib and others can
use it even on 32-bit environment.
This implies the following API addition:
xcb_send_request64()
xcb_discard_reply64()
xcb_wait_for_reply64()
xcb_poll_for_reply64()
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=71338
Reviewed-by: Uli Schlachter <psychon@znc.in>
Signed-off-by: Christian Linhart <chris@demorecorder.com>
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Diffstat (limited to 'src/xcb_in.c')
-rw-r--r-- | src/xcb_in.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/xcb_in.c b/src/xcb_in.c index ad870c1..623a0a8 100644 --- a/src/xcb_in.c +++ b/src/xcb_in.c @@ -523,6 +523,20 @@ void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_ return ret; } +void *xcb_wait_for_reply64(xcb_connection_t *c, uint64_t request, xcb_generic_error_t **e) +{ + void *ret; + if(e) + *e = 0; + if(c->has_error) + return 0; + + pthread_mutex_lock(&c->iolock); + ret = wait_for_reply(c, request, e); + pthread_mutex_unlock(&c->iolock); + return ret; +} + int *xcb_get_reply_fds(xcb_connection_t *c, void *reply, size_t reply_size) { return (int *) (&((char *) reply)[reply_size]); @@ -595,6 +609,20 @@ void xcb_discard_reply(xcb_connection_t *c, unsigned int sequence) pthread_mutex_unlock(&c->iolock); } +void xcb_discard_reply64(xcb_connection_t *c, uint64_t sequence) +{ + if(c->has_error) + return; + + /* If an error occurred when issuing the request, fail immediately. */ + if(!sequence) + return; + + pthread_mutex_lock(&c->iolock); + discard_reply(c, sequence); + pthread_mutex_unlock(&c->iolock); +} + int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply, xcb_generic_error_t **error) { int ret; @@ -612,6 +640,23 @@ int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply, return ret; } +int xcb_poll_for_reply64(xcb_connection_t *c, uint64_t request, void **reply, xcb_generic_error_t **error) +{ + int ret; + if(c->has_error) + { + *reply = 0; + if(error) + *error = 0; + return 1; /* would not block */ + } + assert(reply != 0); + pthread_mutex_lock(&c->iolock); + ret = poll_for_reply(c, request, reply, error); + pthread_mutex_unlock(&c->iolock); + return ret; +} + xcb_generic_event_t *xcb_wait_for_event(xcb_connection_t *c) { xcb_generic_event_t *ret; |