mirror of
https://github.com/apache/nuttx.git
synced 2026-05-25 01:39:44 +08:00
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:
committed by
Xiang Xiao
parent
3fa62118f1
commit
8db732afb1
@@ -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 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user