diff --git a/include/nuttx/list.h b/include/nuttx/list.h index 49d945d04ac..2f26d8304d3 100644 --- a/include/nuttx/list.h +++ b/include/nuttx/list.h @@ -138,20 +138,27 @@ } \ while (0) -#define list_delete(item) \ +#define list_delete_fast(item) \ do \ { \ FAR struct list_node *__item = (item); \ __item->next->prev = __item->prev; \ __item->prev->next = __item->next; \ - __item->prev = __item->next = NULL; \ + } \ + while (0) + +#define list_delete(item) \ + do \ + { \ + list_delete_fast(item); \ + list_clear_node(item); \ } \ while (0) #define list_delete_init(item) \ do \ { \ - list_delete(item); \ + list_delete_fast(item); \ list_initialize(item); \ } \ while (0) diff --git a/include/nuttx/wdog.h b/include/nuttx/wdog.h index cca5e90c43f..d939242bd8b 100644 --- a/include/nuttx/wdog.h +++ b/include/nuttx/wdog.h @@ -39,7 +39,7 @@ * Pre-processor Definitions ****************************************************************************/ -#define WDOG_ISACTIVE(w) (list_in_list(&((w)->node))) +#define WDOG_ISACTIVE(w) ((w)->func != NULL) /* The maximum delay tick are supposed to be CLOCK_MAX >> 1. * However, if there are expired wdog timers in the wdog queue, diff --git a/sched/wdog/wd_cancel.c b/sched/wdog/wd_cancel.c index 143c159010e..6bdf30b3175 100644 --- a/sched/wdog/wd_cancel.c +++ b/sched/wdog/wd_cancel.c @@ -84,7 +84,11 @@ int wd_cancel(FAR struct wdog_s *wdog) /* Now, remove the watchdog from the timer queue */ - list_delete(&wdog->node); + list_delete_fast(&wdog->node); + + /* Mark the watchdog inactive */ + + wdog->func = NULL; spin_unlock_irqrestore(&g_wdspinlock, flags); diff --git a/sched/wdog/wd_start.c b/sched/wdog/wd_start.c index 77a50e4f4cf..64a49fb5105 100644 --- a/sched/wdog/wd_start.c +++ b/sched/wdog/wd_start.c @@ -140,12 +140,13 @@ static inline_function void wd_expiration(clock_t ticks) /* Remove the watchdog from the head of the list */ - list_delete(&wdog->node); + list_delete_fast(&wdog->node); /* Indicate that the watchdog is no longer active. */ func = wdog->func; arg = wdog->arg; + wdog->func = NULL; /* Execute the watchdog function */ @@ -286,7 +287,7 @@ int wd_start_abstick(FAR struct wdog_s *wdog, clock_t ticks, if (WDOG_ISACTIVE(wdog)) { reassess |= list_is_head(&g_wdactivelist, &wdog->node); - list_delete(&wdog->node); + list_delete_fast(&wdog->node); } reassess |= wd_insert(wdog, ticks, wdentry, arg); @@ -312,7 +313,7 @@ int wd_start_abstick(FAR struct wdog_s *wdog, clock_t ticks, if (WDOG_ISACTIVE(wdog)) { - list_delete(&wdog->node); + list_delete_fast(&wdog->node); } wd_insert(wdog, ticks, wdentry, arg);