summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPauli Nieminen <ext-pauli.nieminen@nokia.com>2011-02-01 21:24:58 +0200
committerPauli Nieminen <ext-pauli.nieminen@nokia.com>2011-02-04 17:36:04 +0200
commitdd9d1840e9c091c066c3e165e81c3ab14069a73e (patch)
tree2bbc4ddb1fd010a34a2a85f51043c07fabaf72d2
parente01d6ef33df7b38749adba7be24ff44eed4c3ad9 (diff)
dri2: Send events only to known clients
If client disconnects and new client gets same id DRI2 events may end to wrong client. DRI2 reference list can be checked to see if the client still owns the DRI2Drawable. Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
-rw-r--r--hw/xfree86/dri2/dri2.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index d0aecb4bd..15d2e7a2e 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -255,7 +255,8 @@ DRI2LookupClientDrawableRef(DRI2DrawablePtr pPriv, ClientPtr client, XID id)
DRI2DrawableRefPtr ref;
list_for_each_entry(ref, &pPriv->reference_list, link) {
- if (CLIENT_ID(ref->dri2_id) == client->index && ref->id == id)
+ if (CLIENT_ID(ref->dri2_id) == client->index &&
+ (id == 0 || ref->id == id))
return ref;
}
return NULL;
@@ -740,22 +741,24 @@ DRI2WaitMSCComplete(int client_index, DRI2DrawablePtr pPriv, int frame,
unsigned int tv_sec, unsigned int tv_usec)
{
ClientPtr client = clients[client_index];
+ DRI2DrawableRefPtr ref = DRI2LookupClientDrawableRef(pPriv, client, 0);
+ ClientPtr blockedClient = pPriv->blockedClient;
+ pPriv->blockedClient = NULL;
+ pPriv->blockedOnMsc = FALSE;
pPriv->refcnt--;
- if (pPriv->refcnt == 0) {
- DRI2DrawableGone(pPriv, 0);
+ if (ref == NULL) {
+ if (pPriv->refcnt == 0)
+ DRI2DrawableGone(pPriv, 0);
return;
}
ProcDRI2WaitMSCReply(client, ((CARD64)tv_sec * 1000000) + tv_usec,
frame, pPriv->swap_count);
- if (pPriv->blockedClient)
- AttendClient(pPriv->blockedClient);
-
- pPriv->blockedClient = NULL;
- pPriv->blockedOnMsc = FALSE;
+ if (blockedClient)
+ AttendClient(blockedClient);
}
static void
@@ -809,6 +812,7 @@ DRI2SwapComplete(int client_index, DRI2DrawablePtr pPriv, int frame,
{
ClientPtr client = clients[client_index];
DRI2SwapCompleteDataPtr pSwapData = swap_data;
+ DRI2DrawableRefPtr ref = DRI2LookupClientDrawableRef(pPriv, client, 0);
DrawablePtr pDraw = pPriv->drawable;
CARD64 ust = 0;
@@ -816,6 +820,9 @@ DRI2SwapComplete(int client_index, DRI2DrawablePtr pPriv, int frame,
pPriv->swap_count++;
pPriv->refcnt--;
+ if (ref == NULL)
+ goto out;
+
if (pDraw) {
BoxRec box;
RegionRec region;
@@ -839,6 +846,7 @@ DRI2SwapComplete(int client_index, DRI2DrawablePtr pPriv, int frame,
DRI2WakeClient(client, pPriv, frame, tv_sec, tv_usec);
+out:
free_swap_complete_data(pPriv, pSwapData);
if (pPriv->refcnt == 0)