mirror of
https://github.com/espressif/esp-mqtt.git
synced 2025-09-25 06:31:34 +02:00
fix: Allow mqtt client to gracefully disconnect when stop
Previously the failure to create a disconnect message would lead the client to an incorrect state if called in the process of destroy.
This commit is contained in:
committed by
Rocha Euripedes
parent
09fb84db9d
commit
6bc96ca0b3
@@ -1942,10 +1942,7 @@ esp_err_t esp_mqtt_client_stop(esp_mqtt_client_handle_t client)
|
|||||||
|
|
||||||
// Only send the disconnect message if the client is connected
|
// Only send the disconnect message if the client is connected
|
||||||
if (client->state == MQTT_STATE_CONNECTED) {
|
if (client->state == MQTT_STATE_CONNECTED) {
|
||||||
if (send_disconnect_msg(client) != ESP_OK) {
|
send_disconnect_msg(client);
|
||||||
MQTT_API_UNLOCK(client);
|
|
||||||
return ESP_FAIL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
client->run = false;
|
client->run = false;
|
||||||
|
Reference in New Issue
Block a user