Add new management function to struct timer_list
Make sure that del_timer succeeds and removes an entry from the list. Currently sending the LOCATION UPDATING REJECT from within the timer will not remove the list element as ->active gets set to 0 in the timer updating before calling the callback. Fix the segfault and allow the timer to be removed from within its own callback.
This commit is contained in:
parent
219518d064
commit
b8f04ea5a9
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2008 by Holger Hans Peter Freyther <zecke@selfish.org>
|
* (C) 2008, 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
|
||||||
* All Rights Reserved
|
* All Rights Reserved
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -46,6 +46,7 @@ struct timer_list {
|
||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
int active : 1;
|
int active : 1;
|
||||||
int handled : 1;
|
int handled : 1;
|
||||||
|
int in_list : 1;
|
||||||
|
|
||||||
void (*cb)(void*);
|
void (*cb)(void*);
|
||||||
void *data;
|
void *data;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2008 by Holger Hans Peter Freyther <zecke@selfish.org>
|
* (C) 2008,2009 by Holger Hans Peter Freyther <zecke@selfish.org>
|
||||||
* All Rights Reserved
|
* All Rights Reserved
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -43,6 +43,7 @@ void add_timer(struct timer_list *timer)
|
||||||
if (timer == list_timer)
|
if (timer == list_timer)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
timer->in_list = 1;
|
||||||
llist_add(&timer->entry, &timer_list);
|
llist_add(&timer->entry, &timer_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,8 +61,9 @@ void schedule_timer(struct timer_list *timer, int seconds, int microseconds)
|
||||||
|
|
||||||
void del_timer(struct timer_list *timer)
|
void del_timer(struct timer_list *timer)
|
||||||
{
|
{
|
||||||
if (timer_pending(timer)) {
|
if (timer->in_list) {
|
||||||
timer->active = 0;
|
timer->active = 0;
|
||||||
|
timer->in_list = 0;
|
||||||
llist_del(&timer->entry);
|
llist_del(&timer->entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue