]> granicus.if.org Git - esp-idf/commit
esp_timer: do not allow deleting timers while callbacks are dispatched
authorIvan Grokhotkov <ivan@espressif.com>
Wed, 19 Dec 2018 07:53:50 +0000 (15:53 +0800)
committerbot <bot@espressif.com>
Thu, 3 Jan 2019 07:14:53 +0000 (07:14 +0000)
commit227f8daef3c6e1bfdf23b16b33bbe9f8b2f5fb42
tree22b4a47ef705e9a82c084e8d3cde9f9a1be514e4
parent3c94b6e10a471223616564bfc9b9c88232e749e6
esp_timer: do not allow deleting timers while callbacks are dispatched

timer_process_alarm function of esp_timer holds a spinlock for the
entire duration of its operation, except for the time when timer
callback function is called. It is possible that when
timer_process_alarm releases the spinlock, a higher priority task may
run and delete the timer. Then the execution will return to
timer_process_alarm, and this will either cause a crash, or undesired
execution of callback after the timer has been stopped or deleted.

To solve this problem, add a mutex which will prevent deletion of timers
while callbacks are being dispatched.
components/esp32/esp_timer.c