* The timer thread accessed a timer (to delete the TIMER_IS_RUNNING flag) after
it had been removed from the list. Now, I removed the flag again (but kept the flags field for now), and solved in a way that doesn't have this problem. * This might have a positive effect on #2682. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27574 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
1dd3b2c724
commit
5d6d0dcfc3
@ -20,8 +20,6 @@
|
||||
#include "stack_private.h"
|
||||
|
||||
|
||||
#define TIMER_IS_RUNNING 0x80000000
|
||||
|
||||
// internal Fifo class which doesn't maintain it's own lock
|
||||
// TODO: do we need this one for anything?
|
||||
class Fifo {
|
||||
@ -58,6 +56,7 @@ static struct list sTimers;
|
||||
static mutex sTimerLock;
|
||||
static sem_id sTimerWaitSem;
|
||||
static ConditionVariable sWaitForTimerCondition;
|
||||
static net_timer* sCurrentTimer;
|
||||
static thread_id sTimerThread;
|
||||
static bigtime_t sTimerTimeout;
|
||||
|
||||
@ -441,14 +440,15 @@ timer_thread(void* /*data*/)
|
||||
// execute timer
|
||||
list_remove_item(&sTimers, timer);
|
||||
timer->due = -1;
|
||||
timer->flags |= TIMER_IS_RUNNING;
|
||||
sCurrentTimer = timer;
|
||||
|
||||
mutex_unlock(&sTimerLock);
|
||||
timer->hook(timer, timer->data);
|
||||
mutex_lock(&sTimerLock);
|
||||
|
||||
timer->flags &= ~TIMER_IS_RUNNING;
|
||||
sCurrentTimer = NULL;
|
||||
sWaitForTimerCondition.NotifyAll();
|
||||
|
||||
timer = NULL;
|
||||
// restart scanning as we unlocked the list
|
||||
} else {
|
||||
@ -543,7 +543,7 @@ wait_for_timer(struct net_timer* timer)
|
||||
while (true) {
|
||||
MutexLocker locker(sTimerLock);
|
||||
|
||||
if (timer->due <= 0 && (timer->flags & TIMER_IS_RUNNING) == 0)
|
||||
if (timer->due <= 0 && sCurrentTimer != timer)
|
||||
return;
|
||||
|
||||
// we actually need to wait for this timer
|
||||
|
Loading…
x
Reference in New Issue
Block a user