From 5d6d0dcfc3b65d7d2358c5c6b01a0e12ec22aa41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 15 Sep 2008 16:51:59 +0000 Subject: [PATCH] * 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 --- src/add-ons/kernel/network/stack/utility.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/add-ons/kernel/network/stack/utility.cpp b/src/add-ons/kernel/network/stack/utility.cpp index 3929716342..81232b50e7 100644 --- a/src/add-ons/kernel/network/stack/utility.cpp +++ b/src/add-ons/kernel/network/stack/utility.cpp @@ -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