You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2026/01/08 14:26:21 UTC
(nuttx) 03/05: sched/hrtimer: Fix functional correctness issue.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 8db732afb1f526c65cc1e812732b246f6f2715f7
Author: ouyangxiangzhen <ou...@xiaomi.com>
AuthorDate: Wed Jan 7 11:33:44 2026 +0800
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 <ou...@xiaomi.com>
---
sched/hrtimer/hrtimer_cancel.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/sched/hrtimer/hrtimer_cancel.c b/sched/hrtimer/hrtimer_cancel.c
index 27e53f0725f..c27c2a3a412 100644
--- a/sched/hrtimer/hrtimer_cancel.c
+++ b/sched/hrtimer/hrtimer_cancel.c
@@ -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 */