forked from espressif/esp-mqtt
outbox: Cleanup all items when connection closes
This commit is contained in:
@ -58,6 +58,7 @@ esp_err_t outbox_set_tick(outbox_handle_t outbox, int msg_id, outbox_tick_t tick
|
||||
int outbox_get_size(outbox_handle_t outbox);
|
||||
esp_err_t outbox_cleanup(outbox_handle_t outbox, int max_size);
|
||||
void outbox_destroy(outbox_handle_t outbox);
|
||||
void outbox_delete_all_items(outbox_handle_t outbox);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ esp_err_t outbox_cleanup(outbox_handle_t outbox, int max_size)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void outbox_destroy(outbox_handle_t outbox)
|
||||
void outbox_delete_all_items(outbox_handle_t outbox)
|
||||
{
|
||||
outbox_item_handle_t item, tmp;
|
||||
STAILQ_FOREACH_SAFE(item, outbox, next, tmp) {
|
||||
@ -232,6 +232,10 @@ void outbox_destroy(outbox_handle_t outbox)
|
||||
free(item->buffer);
|
||||
free(item);
|
||||
}
|
||||
}
|
||||
void outbox_destroy(outbox_handle_t outbox)
|
||||
{
|
||||
outbox_delete_all_items(outbox);
|
||||
free(outbox);
|
||||
}
|
||||
|
||||
|
@ -1494,6 +1494,7 @@ static void esp_mqtt_task(void *pv)
|
||||
|
||||
}
|
||||
esp_transport_close(client->transport);
|
||||
outbox_delete_all_items(client->outbox);
|
||||
xEventGroupSetBits(client->status_bits, STOPPED_BIT);
|
||||
|
||||
vTaskDelete(NULL);
|
||||
|
Reference in New Issue
Block a user