From 44292cc2c40bfa6078cb08cec53a0f445c9d73a6 Mon Sep 17 00:00:00 2001 From: Euripedes Rocha Date: Mon, 14 Oct 2024 12:57:05 +0200 Subject: [PATCH] fix: Race condition when using destroy In a case were destroy is being called by a higher priority task set the STOPPED_BIT before seting the state would lead to a crash. --- mqtt_client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mqtt_client.c b/mqtt_client.c index b848213..9b101ff 100644 --- a/mqtt_client.c +++ b/mqtt_client.c @@ -1763,8 +1763,8 @@ static void esp_mqtt_task(void *pv) } esp_transport_close(client->transport); outbox_delete_all_items(client->outbox); - xEventGroupSetBits(client->status_bits, STOPPED_BIT); client->state = MQTT_STATE_DISCONNECTED; + xEventGroupSetBits(client->status_bits, STOPPED_BIT); vTaskDelete(NULL); }