From f31bf49d94ee21682f90aa86fa6e4ec4753078d8 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Mon, 29 Apr 2019 20:22:25 +0200 Subject: erts: Tidy up some harmless code typos --- erts/emulator/beam/time.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/erts/emulator/beam/time.c b/erts/emulator/beam/time.c index a3069e419a..0936832115 100644 --- a/erts/emulator/beam/time.c +++ b/erts/emulator/beam/time.c @@ -316,7 +316,7 @@ struct ErtsTimerWheel_ { #define ERTS_TW_SLOT_AT_ONCE (-1) #define ERTS_TW_BUMP_LATER_WHEEL(TIW) \ - ((tiw)->pos + ERTS_TW_LATER_WHEEL_SLOT_SIZE >= (TIW)->later.pos) + ((TIW)->pos + ERTS_TW_LATER_WHEEL_SLOT_SIZE >= (TIW)->later.pos) static int bump_later_wheel(ErtsTimerWheel *tiw, int *yield_count_p); @@ -908,7 +908,6 @@ erts_bump_timers(ErtsTimerWheel *tiw, ErtsMonotonicTime curr_time) { ErtsMonotonicTime tmp_slots = bump_to - tiw->pos; - tmp_slots = (bump_to - tiw->pos); if (tmp_slots < ERTS_TW_SOON_WHEEL_SIZE) slots = (int) tmp_slots; else -- cgit v1.2.1 From 4d3a7b85af410122932401eeac8c1084fdfdb5ae Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Mon, 29 Apr 2019 20:24:04 +0200 Subject: erts: Fix bug in timer wheel at cancel during bump yield Symptom: Failed debug assert in find_next_timeout ERTS_TW_ASSERT(tiw->yield_slot == ERTS_TW_SLOT_INACTIVE); Problem: If remove_timer() was called in between yielding erts_bump_timers() tiw->true_next_timeout_time could be set to 0 leading to find_next_timeout() being called before all bumping is done. Solution: Don't clear tiw->true_next_timeout_time in remove_timer() if tiw->yield_slot is active. Does not seem this bug could cause other more harmful symptoms, but not sure. --- erts/emulator/beam/time.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/erts/emulator/beam/time.c b/erts/emulator/beam/time.c index 0936832115..9eb020d070 100644 --- a/erts/emulator/beam/time.c +++ b/erts/emulator/beam/time.c @@ -701,7 +701,8 @@ remove_timer(ErtsTimerWheel *tiw, ErtsTWheelTimer *p) if (slot < ERTS_TW_SOON_WHEEL_END_SLOT) { if (empty_slot && tiw->true_next_timeout_time - && p->timeout_pos == tiw->next_timeout_pos) { + && p->timeout_pos == tiw->next_timeout_pos + && tiw->yield_slot == ERTS_TW_SLOT_INACTIVE) { tiw->true_next_timeout_time = 0; } if (--tiw->soon.nto == 0) @@ -714,7 +715,8 @@ remove_timer(ErtsTimerWheel *tiw, ErtsTWheelTimer *p) ErtsMonotonicTime tpos = tiw->later.min_tpos; tpos &= ERTS_TW_LATER_WHEEL_POS_MASK; tpos -= ERTS_TW_LATER_WHEEL_SLOT_SIZE; - if (tpos == tiw->next_timeout_pos) + if (tpos == tiw->next_timeout_pos + && tiw->yield_slot == ERTS_TW_SLOT_INACTIVE) tiw->true_next_timeout_time = 0; } if (--tiw->later.nto == 0) { -- cgit v1.2.1