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
8550997ada
commit
aa48bd8f47
@@ -157,13 +157,19 @@ static esp_err_t ESP_TIMER_IRAM_ATTR timer_restart(esp_timer_handle_t timer, uin
|
||||
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