summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2013-10-17 12:02:27 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2013-10-22 15:44:02 +1000
commit07069f5d71dd0869fe9a6f9ab87c467e7ec75011 (patch)
tree0ad888668e553c67e310059ebbdb95e99fbdb0a6
parentfa5e4dcfb6236b8be0bf57edd1ff4f59cb2f8f6b (diff)
sync: split updating and triggering a counter up
Now that the brackets are always the nearest change points (regardless of transition) we need to update the counters whenever we check for any updates. Otherwise we end up with a situation where counter->value is out of date and an alarm doesn't trigger because we're still using the value from last time something actually triggered. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Keith Packard <keithp@keithp.com> (cherry picked from commit 2523a445a09a75a8baf642608d099a5e12d5437f)
-rw-r--r--Xext/sync.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/Xext/sync.c b/Xext/sync.c
index 7d6b4e0a8..9b4d0a474 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -699,6 +699,14 @@ SyncAwaitTriggerFired(SyncTrigger * pTrigger)
FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
}
+static CARD64
+SyncUpdateCounter(SyncCounter *pCounter, CARD64 newval)
+{
+ CARD64 oldval = pCounter->value;
+ pCounter->value = newval;
+ return oldval;
+}
+
/* This function should always be used to change a counter's value so that
* any triggers depending on the counter will be checked.
*/
@@ -708,8 +716,7 @@ SyncChangeCounter(SyncCounter * pCounter, CARD64 newval)
SyncTriggerList *ptl, *pnext;
CARD64 oldval;
- oldval = pCounter->value;
- pCounter->value = newval;
+ oldval = SyncUpdateCounter(pCounter, newval);
/* run through triggers to see if any become true */
for (ptl = pCounter->sync.pTriglist; ptl; ptl = pnext) {
@@ -2712,6 +2719,8 @@ IdleTimeCheckBrackets(SyncCounter *counter, XSyncValue idle, XSyncValue *less, X
(less && XSyncValueLessOrEqual(idle, *less))) {
SyncChangeCounter(counter, idle);
}
+ else
+ SyncUpdateCounter(counter, idle);
}
static void