diff options
Diffstat (limited to 'src/vppinfra/tw_timer_template.c')
-rw-r--r-- | src/vppinfra/tw_timer_template.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/vppinfra/tw_timer_template.c b/src/vppinfra/tw_timer_template.c index 07e300f5eac..174ffaceb47 100644 --- a/src/vppinfra/tw_timer_template.c +++ b/src/vppinfra/tw_timer_template.c @@ -421,7 +421,6 @@ TW (tw_timer_wheel_init) (TWT (tw_timer_wheel) * tw, } tw->timer_interval = timer_interval_in_seconds; tw->ticks_per_second = 1.0 / timer_interval_in_seconds; - tw->first_expires_tick = ~0ULL; vec_validate (tw->expired_timer_handles, 0); _vec_len (tw->expired_timer_handles) = 0; @@ -514,7 +513,7 @@ static inline u32 slow_wheel_index __attribute__ ((unused)); u32 glacier_wheel_index __attribute__ ((unused)); - /* Shouldn't happen */ + /* Called too soon to process new timer expirations? */ if (PREDICT_FALSE (now < tw->next_run_time)) return callback_vector_arg; @@ -526,6 +525,14 @@ static inline /* Remember when we ran, compute next runtime */ tw->next_run_time = (now + tw->timer_interval); + /* First call, or time jumped backwards? */ + if (PREDICT_FALSE + ((tw->last_run_time == 0.0) || (now <= tw->last_run_time))) + { + tw->last_run_time = now; + return callback_vector_arg; + } + if (callback_vector_arg == 0) { _vec_len (tw->expired_timer_handles) = 0; |