mirror of
https://github.com/espressif/esp-mqtt.git
synced 2025-07-30 18:58:07 +02:00
esp_mqtt_abort_connection: Fixed an issue which could result in a race condition and subsequent crash
This commit is contained in:
@ -571,6 +571,7 @@ static esp_err_t esp_mqtt_connect(esp_mqtt_client_handle_t client, int timeout_m
|
|||||||
|
|
||||||
static esp_err_t esp_mqtt_abort_connection(esp_mqtt_client_handle_t client)
|
static esp_err_t esp_mqtt_abort_connection(esp_mqtt_client_handle_t client)
|
||||||
{
|
{
|
||||||
|
MQTT_API_LOCK(client);
|
||||||
esp_transport_close(client->transport);
|
esp_transport_close(client->transport);
|
||||||
client->wait_timeout_ms = client->config->reconnect_timeout_ms;
|
client->wait_timeout_ms = client->config->reconnect_timeout_ms;
|
||||||
client->reconnect_tick = platform_tick_get_ms();
|
client->reconnect_tick = platform_tick_get_ms();
|
||||||
@ -579,6 +580,7 @@ static esp_err_t esp_mqtt_abort_connection(esp_mqtt_client_handle_t client)
|
|||||||
client->event.event_id = MQTT_EVENT_DISCONNECTED;
|
client->event.event_id = MQTT_EVENT_DISCONNECTED;
|
||||||
client->wait_for_ping_resp = false;
|
client->wait_for_ping_resp = false;
|
||||||
esp_mqtt_dispatch_event_with_msgid(client);
|
esp_mqtt_dispatch_event_with_msgid(client);
|
||||||
|
MQTT_API_UNLOCK(client);
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user