From a96e91db3b7360ab8601d7adca22fc9a0b58d03a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 15 Apr 2009 10:21:58 +0000 Subject: [PATCH] * Added TRACE macro to see what timers are set/cancelled. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30166 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/network/stack/utility.cpp | 27 +++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/add-ons/kernel/network/stack/utility.cpp b/src/add-ons/kernel/network/stack/utility.cpp index 0742c66e91..c58064c9e0 100644 --- a/src/add-ons/kernel/network/stack/utility.cpp +++ b/src/add-ons/kernel/network/stack/utility.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2009, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -20,6 +20,14 @@ #include "stack_private.h" +//#define TRACE_UTILITY +#ifdef TRACE_UTILITY +# define TRACE(x...) dprintf(x) +#else +# define TRACE(x...) ; +#endif + + // internal Fifo class which doesn't maintain it's own lock // TODO: do we need this one for anything? class Fifo { @@ -489,19 +497,21 @@ init_timer(net_timer* timer, net_timer_func hook, void* data) } -/*! - Sets or cancels a timer. When the \a delay is below zero, an eventually running - timer is canceled, if not, it is scheduled to be executed after the specified - \a delay. +/*! Sets or cancels a timer. When the \a delay is below zero, an eventually + running timer is canceled, if not, it is scheduled to be executed after the + specified \a delay. You need to have initialized the timer before calling this function. - In case you need to change a running timer, you have to cancel it first, before - making any changes. + + In case you need to change a running timer, you have to cancel it first, + before making any changes. */ void set_timer(net_timer* timer, bigtime_t delay) { MutexLocker locker(sTimerLock); + TRACE("set_timer %p, hook %p, data %p\n", timer, timer->hook, timer->data); + if (timer->due > 0 && delay < 0) { // this timer is scheduled, cancel it list_remove_item(&sTimers, timer); @@ -527,6 +537,9 @@ cancel_timer(struct net_timer* timer) { MutexLocker locker(sTimerLock); + TRACE("cancel_timer %p, hook %p, data %p\n", timer, timer->hook, + timer->data); + if (timer->due <= 0) return false;