timer: Better fix to the timer re-scheduling situation

As it turns out, the previous fix didn't cover the case of a
timer X being re-scheduled inside a timer call back expiring at
the same time as the previous X instance.

Written-by: Pablo Neira Ayuso <pablo@gnumonks.org>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
This commit is contained in:
Pablo Neira Ayuso 2011-11-13 10:11:31 +01:00 committed by Sylvain Munaut
parent cc90d494ce
commit a71b8eaca7
1 changed files with 3 additions and 6 deletions

View File

@ -69,12 +69,9 @@ static void __add_timer(struct osmo_timer_list *timer)
*/ */
void osmo_timer_add(struct osmo_timer_list *timer) void osmo_timer_add(struct osmo_timer_list *timer)
{ {
if (timer->active) { osmo_timer_del(timer);
rb_erase(&timer->node, &timer_root); timer->active = 1;
} else { INIT_LLIST_HEAD(&timer->list);
timer->active = 1;
INIT_LLIST_HEAD(&timer->list);
}
__add_timer(timer); __add_timer(timer);
} }