summaryrefslogtreecommitdiff
path: root/src/XlibInt.c
diff options
context:
space:
mode:
authorChristian Linhart <chris@demorecorder.com>2015-09-07 17:17:32 +0200
committerAdam Jackson <ajax@redhat.com>2015-09-21 12:46:55 -0400
commita72d2d06c002b644b7040a0a9936c8525e092ba8 (patch)
tree5672e758c9c3c604a184b48c2946455ec2d894cb /src/XlibInt.c
parent58af066a764305c506efea7065ef7679369a1a98 (diff)
downloadxorg-lib-libX11-a72d2d06c002b644b7040a0a9936c8525e092ba8.tar.gz
fix for Xlib 32-bit request number issues
Make use of the new 64-bit sequence number API in XCB 1.11.1 to avoid the 32-bit sequence number wrap in libX11. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=71338 Signed-off-by: Christian Linhart <chris@demorecorder.com> Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'src/XlibInt.c')
-rw-r--r--src/XlibInt.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/XlibInt.c b/src/XlibInt.c
index bbc5c826..72969488 100644
--- a/src/XlibInt.c
+++ b/src/XlibInt.c
@@ -167,8 +167,12 @@ void _XPollfdCacheDel(
static int sync_hazard(Display *dpy)
{
- unsigned long span = dpy->request - dpy->last_request_read;
- unsigned long hazard = min((dpy->bufmax - dpy->buffer) / SIZEOF(xReq), 65535 - 10);
+ /*
+ * "span" and "hazard" need to be signed such that the ">=" comparision
+ * works correctly in the case that hazard is greater than 65525
+ */
+ int64_t span = X_DPY_GET_REQUEST(dpy) - X_DPY_GET_LAST_REQUEST_READ(dpy);
+ int64_t hazard = min((dpy->bufmax - dpy->buffer) / SIZEOF(xReq), 65535 - 10);
return span >= 65535 - hazard - 10;
}
@@ -194,7 +198,7 @@ void _XSeqSyncFunction(
xGetInputFocusReply rep;
register xReq *req;
- if ((dpy->request - dpy->last_request_read) >= (65535 - BUFSIZE/SIZEOF(xReq))) {
+ if ((X_DPY_GET_REQUEST(dpy) - X_DPY_GET_LAST_REQUEST_READ(dpy)) >= (65535 - BUFSIZE/SIZEOF(xReq))) {
GetEmptyReq(GetInputFocus, req);
(void) _XReply (dpy, (xReply *)&rep, 0, xTrue);
sync_while_locked(dpy);
@@ -276,9 +280,9 @@ _XSetLastRequestRead(
register Display *dpy,
register xGenericReply *rep)
{
- register unsigned long newseq, lastseq;
+ register uint64_t newseq, lastseq;
- lastseq = dpy->last_request_read;
+ lastseq = X_DPY_GET_LAST_REQUEST_READ(dpy);
/*
* KeymapNotify has no sequence number, but is always guaranteed
* to immediately follow another event, except when generated via
@@ -287,20 +291,21 @@ _XSetLastRequestRead(
if ((rep->type & 0x7f) == KeymapNotify)
return(lastseq);
- newseq = (lastseq & ~((unsigned long)0xffff)) | rep->sequenceNumber;
+ newseq = (lastseq & ~((uint64_t)0xffff)) | rep->sequenceNumber;
if (newseq < lastseq) {
newseq += 0x10000;
- if (newseq > dpy->request) {
+ if (newseq > X_DPY_GET_REQUEST(dpy)) {
(void) fprintf (stderr,
- "Xlib: sequence lost (0x%lx > 0x%lx) in reply type 0x%x!\n",
- newseq, dpy->request,
+ "Xlib: sequence lost (0x%llx > 0x%llx) in reply type 0x%x!\n",
+ (unsigned long long)newseq,
+ (unsigned long long)(X_DPY_GET_REQUEST(dpy)),
(unsigned int) rep->type);
newseq -= 0x10000;
}
}
- dpy->last_request_read = newseq;
+ X_DPY_SET_LAST_REQUEST_READ(dpy, newseq);
return(newseq);
}
@@ -1363,10 +1368,10 @@ static int _XPrintDefaultError(
mesg, BUFSIZ);
fputs(" ", fp);
(void) fprintf(fp, mesg, event->serial);
- XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d",
+ XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%lld",
mesg, BUFSIZ);
fputs("\n ", fp);
- (void) fprintf(fp, mesg, dpy->request);
+ (void) fprintf(fp, mesg, (unsigned long long)(X_DPY_GET_REQUEST(dpy)));
fputs("\n", fp);
if (event->error_code == BadImplementation) return 0;
return 1;
@@ -1720,7 +1725,7 @@ void *_XGetRequest(Display *dpy, CARD8 type, size_t len)
req->reqType = type;
req->length = len / 4;
dpy->bufptr += len;
- dpy->request++;
+ X_DPY_REQUEST_INCREMENT(dpy);
return req;
}