diff --git a/kernel/include/timeout_q.h b/kernel/include/timeout_q.h index a8d6428c91f..75d3aa33a0a 100644 --- a/kernel/include/timeout_q.h +++ b/kernel/include/timeout_q.h @@ -22,6 +22,7 @@ extern "C" { static inline void _init_timeout(struct _timeout *t, _timeout_func_t fn) { + sys_dnode_init(&t->node); t->dticks = _INACTIVE; } diff --git a/kernel/timeout.c b/kernel/timeout.c index 4d539db5ff9..4cd4c05d1f8 100644 --- a/kernel/timeout.c +++ b/kernel/timeout.c @@ -46,14 +46,11 @@ static struct _timeout *next(struct _timeout *t) static void remove_timeout(struct _timeout *t) { - if (t->node.next != NULL && t->node.prev != NULL) { - if (next(t) != NULL) { - next(t)->dticks += t->dticks; - } - - sys_dlist_remove(&t->node); + if (next(t) != NULL) { + next(t)->dticks += t->dticks; } - t->node.next = t->node.prev = NULL; + + sys_dlist_remove(&t->node); t->dticks = _INACTIVE; } @@ -113,7 +110,7 @@ int _abort_timeout(struct _timeout *to) int ret = _INACTIVE; LOCKED(&timeout_lock) { - if (to->dticks != _INACTIVE) { + if (sys_dnode_is_linked(&to->node)) { remove_timeout(to); ret = 0; }