From f0563b384478d9abe4956084ee4b93df2339e05b Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 7 Oct 2019 16:36:18 +0200 Subject: [PATCH] system_api: call shutdown handlers in reverse order Similar to how destructors should be called in reverse order to the constructors. --- components/esp32/system_api.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/components/esp32/system_api.c b/components/esp32/system_api.c index c3d77c01d3..4e28dc31e2 100644 --- a/components/esp32/system_api.c +++ b/components/esp32/system_api.c @@ -230,12 +230,11 @@ void esp_restart_noos(void) __attribute__ ((noreturn)); void IRAM_ATTR esp_restart(void) { - int i; - for (i = 0; i < SHUTDOWN_HANDLERS_NO; i++) { - if (shutdown_handlers[i]) { - shutdown_handlers[i](); - } - } + for (int i = SHUTDOWN_HANDLERS_NO - 1; i >= 0; i--) { + if (shutdown_handlers[i]) { + shutdown_handlers[i](); + } + } // Disable scheduler on this core. vTaskSuspendAll(); -- 2.40.0