diff options
author | Dave Barach <dave@barachs.net> | 2020-03-27 11:14:59 -0400 |
---|---|---|
committer | Dave Barach <dave@barachs.net> | 2020-03-27 12:03:19 -0400 |
commit | b70fd4a545cf8e3bb1c3ddbac3fff6a112a8cbbd (patch) | |
tree | 9885466351e09265d0ad3434c6bf2898cabe3dd6 /src/vppinfra/tw_timer_template.c | |
parent | ffe2caf9da1105c4fedd7c152deea456816eed17 (diff) |
vppinfra: manual cherrypick timebase fixes
Gerrit Headline
------ --------
25729 fix corner cases in tw_timer_expire
25763 improve timebase resilience
25837 remove time jump workaround
Automatic cherry-picking failed miserably.
Type: fix
Ticket: VPP-1852
Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: I460effb2b5f4f19ae4548ef01ca3726b7412bd7f
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; |