From 36eec6f62559c0d38cdb7e88d24ae42793127332 Mon Sep 17 00:00:00 2001 From: Euripedes Rocha Date: Wed, 21 Jun 2023 09:39:42 +0200 Subject: [PATCH] Fix: Stop client only if it's running. Check for client run instead of lock to call esp_mqtt_client_stop when destroying the client. --- mqtt_client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mqtt_client.c b/mqtt_client.c index 52ae7dd..50d8001 100644 --- a/mqtt_client.c +++ b/mqtt_client.c @@ -877,7 +877,7 @@ esp_err_t esp_mqtt_client_destroy(esp_mqtt_client_handle_t client) if (client == NULL) { return ESP_ERR_INVALID_ARG; } - if (client->api_lock) { + if (client->run) { esp_mqtt_client_stop(client); } esp_mqtt_destroy_config(client);