Index: timer.c =================================================================== RCS file: /cvsroot/ser/sip_router/modules/tm/timer.c,v retrieving revision 1.58.2.3 diff -u -r1.58.2.3 timer.c --- timer.c 6 Dec 2005 13:20:14 -0000 1.58.2.3 +++ timer.c 28 Nov 2006 14:56:28 -0000 @@ -98,6 +98,8 @@ * 2003-06-27 timers are not unlinked if timerlist is 0 (andrei) * 2004-02-13 t->is_invite, t->local, t->noisy_ctimer replaced; * timer_link.payload removed (bogdan) + * 2006-11-28 switched to using the new timer_link flag for the timer + * deleted check (andrei) */ #include "defs.h" @@ -536,7 +538,9 @@ struct timer_table *tm_init_timers() { enum lists i; - +#ifdef TIMER_DELETED_FLAG + LOG(L_CRIT, "timer init, TIMER_DELETED_FLAG suppport\n"); +#endif timertable=(struct timer_table *) shm_malloc(sizeof(struct timer_table)); if (!timertable) { LOG(L_ERR, "ERROR: tm_init_timers: no shmem for timer_Table\n"); @@ -660,7 +664,7 @@ ptr = ptr->prev_tl) { if ( #ifdef TIMER_SKIP_DELETED - (ptr->time_out != TIMER_DELETED) && + (!timer_is_deleted(ptr)) && #endif (ptr->time_out <= time_out)) break; } @@ -770,7 +774,11 @@ but not execute; there is a race condition, though -- see timer.c for more details */ +#ifdef TIMER_DELETED_FLAG + tl->is_deleted=1; +#else tl->time_out = TIMER_DELETED; +#endif #ifdef EXTRA_DEBUG DBG("DEBUG: reset_timer (group %d, tl=%p)\n", tl->tg, tl ); #endif @@ -854,7 +862,7 @@ list= &(timertable->timers[ list_id ]); lock(list->mutex); - if (!(new_tl->time_out>TIMER_DELETED)) { + if (!(timer_is_active(new_tl))) { /* make sure I'm not already on a list */ /* remove_timer_unsafe( new_tl ); */ /* @@ -944,7 +952,7 @@ (_tl)->next_tl = (_tl)->prev_tl = 0;\ DBG("DEBUG: timer routine:%d,tl=%p next=%p\n",\ id,(_tl),tmp_tl);\ - if ((_tl)->time_out>TIMER_DELETED) \ + if (timer_is_active(_tl)) \ (_handler)( _tl );\ (_tl) = tmp_tl;\ } Index: timer.h =================================================================== RCS file: /cvsroot/ser/sip_router/modules/tm/timer.h,v retrieving revision 1.37 diff -u -r1.37 timer.h --- timer.h 1 Nov 2004 14:09:09 -0000 1.37 +++ timer.h 28 Nov 2006 14:56:28 -0000 @@ -29,6 +29,8 @@ * -------- * 2003-09-12 timer_link.tg exists only if EXTRA_DEBUG (andrei) * 2004-02-13 timer_link.payload removed (bogdan) + * 2006-11-28 added a special is_deleted flag for the timer_link structure, + * added timer_is_deleted() and timer_is_active() (andrei) */ @@ -42,9 +44,16 @@ /* timer timestamp value indicating a timer has been deactivated and shall not be executed */ -#define TIMER_DELETED 1 - +#define TIMER_DELETED_FLAG +#ifdef TIMER_DELETED_FLAG + #define timer_is_deleted(tl) (tl->is_deleted) + #define timer_is_active(tl) ( ! tl->is_deleted && tl->time_out!=0) +#else + #define TIMER_DELETED 1 + #define timer_is_deleted(tl) (tl->time_out==TIMER_DELETED) + #define timer_is_active(tl) (tl->time_out>TIMER_DELETED) +#endif /* identifiers of timer lists;*/ /* fixed-timer retransmission lists (benefit: fixed timer$ @@ -67,6 +76,9 @@ struct timer_link *prev_tl; volatile unsigned int time_out; struct timer *timer_list; +#ifdef TIMER_DELETED_FLAG + volatile char is_deleted; +#endif #ifdef EXTRA_DEBUG enum timer_groups tg; #endif