mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 17:19:09 -04:00
Merge branch 'fix/common_connect_sema_race' into 'master'
fix(connect): Fix wifi_connect to delete semaphores after waiting on them See merge request espressif/esp-idf!37164
This commit is contained in:
commit
9715729b27
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
*/
|
*/
|
||||||
@ -172,9 +172,13 @@ esp_err_t example_wifi_sta_do_connect(wifi_config_t wifi_config, bool wait)
|
|||||||
ESP_LOGI(TAG, "Waiting for IP(s)");
|
ESP_LOGI(TAG, "Waiting for IP(s)");
|
||||||
#if CONFIG_EXAMPLE_CONNECT_IPV4
|
#if CONFIG_EXAMPLE_CONNECT_IPV4
|
||||||
xSemaphoreTake(s_semph_get_ip_addrs, portMAX_DELAY);
|
xSemaphoreTake(s_semph_get_ip_addrs, portMAX_DELAY);
|
||||||
|
vSemaphoreDelete(s_semph_get_ip_addrs);
|
||||||
|
s_semph_get_ip_addrs = NULL;
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_EXAMPLE_CONNECT_IPV6
|
#if CONFIG_EXAMPLE_CONNECT_IPV6
|
||||||
xSemaphoreTake(s_semph_get_ip6_addrs, portMAX_DELAY);
|
xSemaphoreTake(s_semph_get_ip6_addrs, portMAX_DELAY);
|
||||||
|
vSemaphoreDelete(s_semph_get_ip6_addrs);
|
||||||
|
s_semph_get_ip6_addrs = NULL;
|
||||||
#endif
|
#endif
|
||||||
if (s_retry_num > CONFIG_EXAMPLE_WIFI_CONN_MAX_RETRY) {
|
if (s_retry_num > CONFIG_EXAMPLE_WIFI_CONN_MAX_RETRY) {
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
@ -190,14 +194,6 @@ esp_err_t example_wifi_sta_do_disconnect(void)
|
|||||||
ESP_ERROR_CHECK(esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_STA_CONNECTED, &example_handler_on_wifi_connect));
|
ESP_ERROR_CHECK(esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_STA_CONNECTED, &example_handler_on_wifi_connect));
|
||||||
#if CONFIG_EXAMPLE_CONNECT_IPV6
|
#if CONFIG_EXAMPLE_CONNECT_IPV6
|
||||||
ESP_ERROR_CHECK(esp_event_handler_unregister(IP_EVENT, IP_EVENT_GOT_IP6, &example_handler_on_sta_got_ipv6));
|
ESP_ERROR_CHECK(esp_event_handler_unregister(IP_EVENT, IP_EVENT_GOT_IP6, &example_handler_on_sta_got_ipv6));
|
||||||
#endif
|
|
||||||
if (s_semph_get_ip_addrs) {
|
|
||||||
vSemaphoreDelete(s_semph_get_ip_addrs);
|
|
||||||
}
|
|
||||||
#if CONFIG_EXAMPLE_CONNECT_IPV6
|
|
||||||
if (s_semph_get_ip6_addrs) {
|
|
||||||
vSemaphoreDelete(s_semph_get_ip6_addrs);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
return esp_wifi_disconnect();
|
return esp_wifi_disconnect();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user