X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvppinfra%2Ftw_timer_template.c;h=e78c309ebaa3543294529710bc397e0e2bfdb08e;hb=31844c62b5b3af88cb688bbd33783b1146d0eb55;hp=af2b75a0f57971aa644ea95e1b36565d93992dd6;hpb=90d28846f963a86d760b4a6b83aed62b862f1c61;p=vpp.git diff --git a/src/vppinfra/tw_timer_template.c b/src/vppinfra/tw_timer_template.c index af2b75a0f57..e78c309ebaa 100644 --- a/src/vppinfra/tw_timer_template.c +++ b/src/vppinfra/tw_timer_template.c @@ -513,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; @@ -525,6 +525,28 @@ 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; + } + + /* + * Refuse to do anything if we're about to process way too many slots. + * Should never come anywhere close to happening, with the possible exception + * of cases involving a large forward jump in the timebase. + */ + if (nticks > (1 << (TW_RING_SHIFT + 1))) + { + if (nticks / tw->ticks_per_second > 100e-3) + clib_warning ("Excessive nticks %u at %.6f last run %.6f", + nticks, 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;