summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Barnes <jbarnes@virtuousgeek.org>2010-03-08 12:41:25 -0800
committerPeter Hutterer <peter.hutterer@who-t.net>2010-05-21 13:55:30 +1000
commit5c54e7fa004532d595160a815177dda467b3cc9c (patch)
treec66f78b1e69b3ab58e57bc34b5b795049494d716
parentfcd76ddfc59de6a1d37ca2aa6e6e91cb8d814744 (diff)
DRI2: handle swapsPending better
Avoid a potential swapsPending underflow by incrementing it before ScheduleSwap, which may complete it immediately. And be sure to decrement it again in case the schedule failed. Reported-by: Mario Kleiner <mario.kleiner@tuebingen.mpg.de> Reviewed-by: Mario Kleiner <mario.kleiner@tuebingen.mpg.de> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org> (cherry picked from commit b00d435ddf2e9817e33bfd5f7e9b905442dc23c7)
-rw-r--r--hw/xfree86/dri2/dri2.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 3fc7f4ee2..8a671226f 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -654,15 +654,16 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
*swap_target = target_msc;
}
+ pPriv->swapsPending++;
ret = (*ds->ScheduleSwap)(client, pDraw, pDestBuffer, pSrcBuffer,
swap_target, divisor, remainder, func, data);
if (!ret) {
+ pPriv->swapsPending--; /* didn't schedule */
xf86DrvMsg(pScreen->myNum, X_ERROR,
"[DRI2] %s: driver failed to schedule swap\n", __func__);
return BadDrawable;
}
- pPriv->swapsPending++;
pPriv->last_swap_target = *swap_target;
/* According to spec, return expected swapbuffers count SBC after this swap