From: Ivan Grokhotkov Date: Mon, 8 Apr 2019 11:30:32 +0000 (+0800) Subject: tcpip_adapter: unregister shutdown handlers, don’t fail on repeated registration X-Git-Tag: v4.0-beta1~415^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=198d7d47547c296ae4d9a8500410e461fd58ba2e;p=esp-idf tcpip_adapter: unregister shutdown handlers, don’t fail on repeated registration --- diff --git a/components/tcpip_adapter/event_handlers.c b/components/tcpip_adapter/event_handlers.c index ff7847b286..99e4342a42 100644 --- a/components/tcpip_adapter/event_handlers.c +++ b/components/tcpip_adapter/event_handlers.c @@ -242,7 +242,7 @@ esp_err_t tcpip_adapter_set_default_wifi_handlers() } err = esp_register_shutdown_handler((shutdown_handler_t)esp_wifi_stop); - if (err != ESP_OK) { + if (err != ESP_OK && err != ESP_ERR_INVALID_STATE) { goto fail; } @@ -263,8 +263,7 @@ esp_err_t tcpip_adapter_clear_default_wifi_handlers() esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_AP_STOP, handle_ap_stop); esp_event_handler_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, handle_sta_got_ip); esp_event_handler_unregister(IP_EVENT, IP_EVENT_ETH_GOT_IP, handle_eth_got_ip); - - /* TODO: introduce esp_unregister_shutdown_handler or similar, call it here */ + esp_unregister_shutdown_handler((shutdown_handler_t)esp_wifi_stop); return ESP_OK; }