From a326b057b37ecbaa2f14b8a6f1d91e454198b1d5 Mon Sep 17 00:00:00 2001 From: sg Date: Wed, 27 Jul 2016 21:16:22 +0200 Subject: [PATCH] Fix bug #48568 (timeouts does not support late firing properly) by assuming sys_check_timeouts() jitter can' be too bad --- src/core/timeouts.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/core/timeouts.c b/src/core/timeouts.c index e630b7e2..9411800e 100644 --- a/src/core/timeouts.c +++ b/src/core/timeouts.c @@ -246,6 +246,12 @@ sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg) if (t->next == NULL || t->next->time > timeout->time) { if (t->next != NULL) { t->next->time -= timeout->time; + } else if (timeout->time > msecs) { + /* If this is the case, 'timeouts_last_time' and 'now' differs too much. + This can be due to sys_check_timeouts() not being called at the right + times, but also when stopping in a breakpoint. Anyway, let's assume + this is not wanted, so add the first timer's time instead of 'diff' */ + timeout->time = msecs + next_timeout->time; } timeout->next = t->next; t->next = timeout;