mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user