From de426c08b6afda91432a1b31df10570835a0a0fa Mon Sep 17 00:00:00 2001 From: Flavio Bayer Date: Fri, 13 Apr 2018 16:08:03 -0300 Subject: [PATCH] bugfix/ets_timer.c: race condition while disarming If `sdk_ets_timer_arm_ms_us` is called right after `vPortExitCritical` inside `sdk_ets_timer_disarm` on line 247 (by an ISR for example, which was my case), execution will loop forever on line 196, since `timer->next!=ETS_TIMER_NOT_ARMED`, which was supposed to be changed in line 248. By delaying the IRS or context switch until `sdk_ets_timer_disarm` the problem is fixed. --- open_esplibs/libmain/ets_timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/open_esplibs/libmain/ets_timer.c b/open_esplibs/libmain/ets_timer.c index 44b3196..7b3ca36 100644 --- a/open_esplibs/libmain/ets_timer.c +++ b/open_esplibs/libmain/ets_timer.c @@ -244,9 +244,9 @@ void sdk_ets_timer_disarm(ets_timer_t *timer) prev = curr; curr = curr->next; } - vPortExitCritical(); timer->next = ETS_TIMER_NOT_ARMED; timer->period_ticks = 0; + vPortExitCritical(); } /**