struct retry_timer {
/** List of active timers */
struct list_head list;
+ /** Timer is currently running */
+ unsigned int running;
/** Timeout value (in ticks) */
unsigned long timeout;
/** Minimum timeout value (in ticks)
* A value of zero means "use default timeout."
*/
unsigned long max_timeout;
- /** Start time (in ticks)
- *
- * A start time of zero indicates a stopped timer.
- */
+ /** Start time (in ticks) */
unsigned long start;
/** Retry count */
unsigned int count;
*/
static inline __attribute__ (( always_inline )) unsigned long
timer_running ( struct retry_timer *timer ) {
- return ( timer->start );
+ return ( timer->running );
}
#endif /* _GPXE_RETRY_H */
* be stopped and the timer's callback function will be called.
*/
void start_timer ( struct retry_timer *timer ) {
- if ( ! timer_running ( timer ) )
+ if ( ! timer->running )
list_add ( &timer->list, &timers );
timer->start = currticks();
+ timer->running = 1;
/* 0 means "use default timeout" */
if ( timer->min_timeout == 0 )
void start_timer_fixed ( struct retry_timer *timer, unsigned long timeout ) {
start_timer ( timer );
timer->timeout = timeout;
+ DBG2 ( "Timer %p expiry time changed to %ld\n",
+ timer, ( timer->start + timer->timeout ) );
}
/**
unsigned long runtime;
/* If timer was already stopped, do nothing */
- if ( ! timer_running ( timer ) )
+ if ( ! timer->running )
return;
list_del ( &timer->list );
runtime = ( now - timer->start );
- timer->start = 0;
+ timer->running = 0;
DBG2 ( "Timer %p stopped at time %ld (ran for %ld)\n",
timer, now, runtime );
/* Stop timer without performing RTT calculations */
DBG2 ( "Timer %p stopped at time %ld on expiry\n",
timer, currticks() );
+ assert ( timer->running );
list_del ( &timer->list );
- timer->start = 0;
+ timer->running = 0;
timer->count++;
/* Back off the timeout value */