uloop: fix a regression in timeout handling
authorFelix Fietkau <nbd@nbd.name>
Sat, 17 Jun 2017 09:39:24 +0000 (11:39 +0200)
committerFelix Fietkau <nbd@nbd.name>
Sat, 17 Jun 2017 09:40:11 +0000 (11:40 +0200)
Variable confusion was breaking timers

Fixes: 368fd2645878 ("uloop: allow specifying a timeout for uloop_run()")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
uloop.c

diff --git a/uloop.c b/uloop.c
index f5032418ed6697bf5035cbe3cdedf1c3ff85880b..0c57753444e16f361afd8f2d51a180436323aec9 100644 (file)
--- a/uloop.c
+++ b/uloop.c
@@ -548,9 +548,9 @@ int uloop_run_timeout(int timeout)
                uloop_gettime(&tv);
 
                next_time = uloop_get_next_timeout(&tv);
-               if (timeout > 0 && next_time < timeout)
-                       timeout = next_time;
-               uloop_run_events(timeout);
+               if (timeout > 0 && timeout < next_time)
+                       next_time = timeout;
+               uloop_run_events(next_time);
        }
 
        if (!--uloop_run_depth)