sched/hrtimer: Fix functional correctness issue.

The expired field can not be used to indicate the cancelled state. Because
the `UINT64_MAX` is valid expired time. A periodic hrtimer started with
the hrtimer_start_absolute(hrtimer, period_func, UINT64_MAX) can
not be cancelled via `hrtimer_cancel`.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
This commit is contained in:
ouyangxiangzhen
2026-01-07 11:33:44 +08:00
committed by Xiang Xiao
parent 3fa62118f1
commit 8db732afb1
+4 -2
View File
@@ -131,9 +131,11 @@ int hrtimer_cancel(FAR hrtimer_t *hrtimer)
hrtimer_remove(hrtimer);
}
/* Mark timer as cancelled */
/* If the timer was running, increment its expiration count to prevent
* it from being re-armed by the callback.
*/
hrtimer->expired = UINT64_MAX;
hrtimer->expired++;
/* If the canceled timer was the earliest one, update the hardware timer */