summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2013-10-30 15:40:58 +1000
committerMatt Dew <marcoz@osource.org>2013-11-16 15:15:05 -0700
commit6cc5efa68e5fdc301ab9a381bffe88fe5c7865e2 (patch)
tree731edf6640cff5970913ea8a91d61ae8767e9ec0
parent339af2ae943d943f8ce986fc7bdcb8aa52b44922 (diff)
sync: fix corner-case in triggering idle alarms
ProcessInputEvent() resets the device idle times. If idle time was higher than the lower bracket, this should trigger an event in the idle time wakeup handler. If processing is slow, the idle time may advance past the lower bracket between the reset and the time the BlockHandler is called. In that case, we'd never schedule a wakeup to handle the event, causing us to randomly miss events. Ran tests with a neg transition trigger on 5ms with 200 repeats of the test and it succeeded. Anything below that gets a bit tricky to make sure the server sees the same idle time as the client usleeps for. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Keith Packard <keithp@keithp.com> (cherry picked from commit f36f5a65f639b6524191d888d5bf89e73027156c)
-rw-r--r--Xext/sync.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/Xext/sync.c b/Xext/sync.c
index 9b4d0a474..dd6633f71 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -2654,7 +2654,16 @@ IdleTimeBlockHandler(pointer pCounter, struct timeval **wt, pointer LastSelectMa
IdleTimeQueryValue(counter, &idle);
counter->value = idle; /* push, so CheckTrigger works */
- if (less && XSyncValueLessOrEqual(idle, *less)) {
+ /**
+ * There's an indefinite amount of time between ProcessInputEvents()
+ * where the idle time is reset and the time we actually get here. idle
+ * may be past the lower bracket if we dawdled with the events, so
+ * check for whether we did reset and bomb out of select immediately.
+ */
+ if (less && XSyncValueGreaterThan(idle, *less) &&
+ LastEventTimeWasReset(priv->deviceid)) {
+ AdjustWaitForDelay(wt, 0);
+ } else if (less && XSyncValueLessOrEqual(idle, *less)) {
/*
* We've been idle for less than the threshold value, and someone
* wants to know about that, but now we need to know whether they