On Fri, Nov 11, 2011 at 06:50:31PM +0100, Harald Welte wrote:
> Hi all,
> 
> On Fri, Nov 11, 2011 at 03:56:21PM +0100, Sylvain Munaut wrote:
> > While updating libosmocore in osmocom-bb, a problem arised: 100%CPU
> > usage and hanging. Turns out 'mobile' sometimes call
> > osmo_timer_schedule for an already scheduled timer.
> > 
> > Obviously this used to work and now it doesn't. The question is : Was
> > there a defined semantics for this case previously ? Or is it supposed
> > to be unsupported ? What would you expect it to do ?
> 
> I think a second/follow-up timer_schedule should re-schedule the
> existing timer safely.

The patch attached should recover the former behaviour, sorry for
missing this case.
>From 1a6d416bfb6bcec34188f3bd23847b0e45e0f2f9 Mon Sep 17 00:00:00 2001
From: Pablo Neira Ayuso <[email protected]>
Date: Sat, 12 Nov 2011 22:52:10 +0100
Subject: [PATCH] timer: fix active timer re-scheduling situation

This patch re-adds support the timer re-scheduling situation which
used to be supported until I introduced the rb-tree based timer.

Signed-off-by: Pablo Neira Ayuso <[email protected]>
---
 src/timer.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/timer.c b/src/timer.c
index 6852983..e68040f 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -68,6 +68,7 @@ static void __add_timer(struct osmo_timer_list *timer)
  */
 void osmo_timer_add(struct osmo_timer_list *timer)
 {
+	osmo_timer_del(timer);
 	timer->active = 1;
 	INIT_LLIST_HEAD(&timer->list);
 	__add_timer(timer);
-- 
1.7.2.5

Reply via email to