This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit f495cd4ffda0b88f1d5583866cffc1a4541c287b Author: ouyangxiangzhen <ouyangxiangz...@xiaomi.com> AuthorDate: Thu Jan 16 18:45:23 2025 +0800 sched/wdog: allow wd_cancel_period in the periodical wdog callback. This commit addresses an issue where calling `wd_cancel_period` within the periodic watchdog callback would fail to cancel the watchdog timer. Signed-off-by: ouyangxiangzhen <ouyangxiangz...@xiaomi.com> --- include/nuttx/wdog.h | 7 +++++++ sched/wdog/wd_start.c | 9 ++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/nuttx/wdog.h b/include/nuttx/wdog.h index 393aa73cc9..90ba3fc85f 100644 --- a/include/nuttx/wdog.h +++ b/include/nuttx/wdog.h @@ -31,6 +31,7 @@ #include <nuttx/compiler.h> #include <nuttx/clock.h> +#include <errno.h> #include <stdint.h> /**************************************************************************** @@ -348,6 +349,12 @@ int wd_cancel(FAR struct wdog_s *wdog); static inline int wd_cancel_period(FAR struct wdog_period_s *wdog_period) { + if (!wdog_period) + { + return -EINVAL; + } + + wdog_period->period = 0; return wd_cancel(&wdog_period->wdog); } diff --git a/sched/wdog/wd_start.c b/sched/wdog/wd_start.c index e0e5a640be..c8ba5c2669 100644 --- a/sched/wdog/wd_start.c +++ b/sched/wdog/wd_start.c @@ -118,9 +118,12 @@ static void wdentry_period(wdparm_t arg) * we need to use `expired - 1` here to avoid time drift. */ - wd_start_abstick(&wdperiod->wdog, - wdperiod->wdog.expired + wdperiod->period - 1, - wdentry_period, wdperiod->wdog.arg); + if (wdperiod->period != 0) + { + wd_start_abstick(&wdperiod->wdog, + wdperiod->wdog.expired + wdperiod->period - 1, + wdentry_period, wdperiod->wdog.arg); + } } /****************************************************************************