Merge branch 'fix_destroy' into 'master'

fix: Allow mqtt client to gracefully disconnect when stop

See merge request espressif/esp-mqtt!249
This commit is contained in:
Rocha Euripedes
2025-09-12 19:10:06 +08:00

View File

@@ -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;