timer: if a timer is inactive, do not call the timer func
authorPeter Hutterer <peter.hutterer@who-t.net>
Mon, 17 Jul 2017 01:58:11 +0000 (11:58 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Wed, 6 Sep 2017 09:38:43 +0000 (19:38 +1000)
Race conditions may happen where code that cancels a timer is called just
as that timer triggers. If we cancel a timer, we assume that we've put the
code into a state where the timer firing will trigger a bug.

This could be observed with the middle button code if the release event was
held back just long enough. The button release code cancelled the timer, set
the state back to idle and then complained when the timeout handling sent a
'timeout' event while being in idle.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 696fdff247453e60e259349d0125f67856361b54)

src/timer.c

index 4a7b43a8244b6fd3f0259279e49055aa58630d9e..7a0a8ebf8704bebfaf5bfacb288154d95ac43efc 100644 (file)
@@ -133,6 +133,9 @@ libinput_timer_handler(void *data)
                return;
 
        list_for_each_safe(timer, tmp, &libinput->timer.list, link) {
+               if (timer->expire == 0)
+                       continue;
+
                if (timer->expire <= now) {
                        /* Clear the timer before calling timer_func,
                           as timer_func may re-arm it */