mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 10:40:47 +03:00
fix(esp_timer): prevent restart expiry race
This commit is contained in:
committed by
Konstantin Kondrashov
parent
fd0b33dfda
commit
36a06fe99e
@@ -140,13 +140,19 @@ esp_err_t ESP_TIMER_IRAM_ATTR esp_timer_restart(esp_timer_handle_t timer, uint64
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (!is_initialized() || !timer_armed(timer)) {
|
||||
if (!is_initialized()) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
esp_timer_dispatch_t dispatch_method = timer->flags & FL_ISR_DISPATCH_METHOD;
|
||||
timer_list_lock(dispatch_method);
|
||||
|
||||
/* The timer may expire while this task is waiting for the list lock. */
|
||||
if (!timer_armed(timer)) {
|
||||
timer_list_unlock(dispatch_method);
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
const int64_t now = esp_timer_impl_get_time();
|
||||
const uint64_t period = timer->period;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user