From 4c0b15689aaa5cb69b18a0cfb75ee1bf30b4c9ef Mon Sep 17 00:00:00 2001 From: Roman Gershman Date: Wed, 22 Jan 2025 19:48:50 +0200 Subject: [PATCH] fix: reset next task id during self-deregistration (#373) Signed-off-by: Roman Gershman --- util/fibers/proactor_base.cc | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/util/fibers/proactor_base.cc b/util/fibers/proactor_base.cc index ebdc9160..109a8e5c 100644 --- a/util/fibers/proactor_base.cc +++ b/util/fibers/proactor_base.cc @@ -157,17 +157,20 @@ bool ProactorBase::RunOnIdleTasks() { do { on_idle_arr_.pop_back(); } while (!on_idle_arr_.empty() && !on_idle_arr_.back().task); - break; + on_idle_next_ = 0; + break; // do/while loop + } + } else { // level >= 0 + curr_ts = GetClockNanos(); + + if (unsigned(level) >= kOnIdleMaxLevel) { + level = kOnIdleMaxLevel; + should_spin = true; + } else if (on_idle_next_ < + on_idle_arr_.size()) { // check if the array has not been shrunk. + uint64_t delta_ns = uint64_t(kIdleCycleMaxMicros) * 1000 / (1 << level); + on_idle.next_ts = curr_ts + delta_ns; } - } - curr_ts = GetClockNanos(); - - if (unsigned(level) >= kOnIdleMaxLevel) { - level = kOnIdleMaxLevel; - should_spin = true; - } else if (on_idle_next_ < on_idle_arr_.size()) { // check if the array has not been shrunk. - uint64_t delta_ns = uint64_t(kIdleCycleMaxMicros) * 1000 / (1 << level); - on_idle.next_ts = curr_ts + delta_ns; } }