[PATCH 11/12] DRI2: handle swapsPending better

Jesse Barnes jbarnes at virtuousgeek.org
Mon Mar 22 15:03:41 PDT 2010


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 at tuebingen.mpg.de>
Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org>
---
 hw/xfree86/dri2/dri2.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 3fc7f4e..8a67122 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
-- 
1.6.6.1



More information about the xorg-devel mailing list