Improve wakeup tick condition check

We got a off by one error here, checking against UINT32_MAX doesn't silently set a wrong value.

When running the task mgem with a busy loop this doesn't cause an issue, but with a tickless timer only one timer ever gets fired and then the task mgem stops working.
This commit is contained in:
Hendrik
2026-05-17 07:31:08 +02:00
committed by GitHub
parent 40264c9aad
commit 2668619143
+2 -1
View File
@@ -568,7 +568,8 @@ sleep_us_impl(mrb_state *mrb, uint32_t usec)
t->wait.wakeup_tick = tick_ + USEC_TO_TICKS(usec);
/* Update next wakeup time if this task wakes earlier */
if ((int32_t)(t->wait.wakeup_tick - wakeup_tick_) < 0) {
if (wakeup_tick_ == UINT32_MAX ||
(int32_t)(t->wait.wakeup_tick - wakeup_tick_) < 0) {
wakeup_tick_ = t->wait.wakeup_tick;
}