fixed memory leak in MQTT extended log
This commit is contained in:
parent
133dc249c7
commit
369b236549
|
|
@ -395,12 +395,12 @@ void MQTTTaskTransmit(void *pvParameter)
|
||||||
DSS.data_length,
|
DSS.data_length,
|
||||||
0, 0);
|
0, 0);
|
||||||
}
|
}
|
||||||
//else
|
|
||||||
// ESP_LOGW(TAG, "MQTT client not initialized or disconnected");
|
|
||||||
if (!DSS.keep_memory_onfinish)
|
if (!DSS.keep_memory_onfinish)
|
||||||
|
{
|
||||||
free(DSS.raw_data_ptr);
|
free(DSS.raw_data_ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void start_mqtt()
|
static void start_mqtt()
|
||||||
{
|
{
|
||||||
|
|
@ -547,10 +547,11 @@ esp_err_t ExtendedLog(esp_log_level_t level, char *format, ...)
|
||||||
strcpy(buf, time);
|
strcpy(buf, time);
|
||||||
strcat(buf, " ");
|
strcat(buf, " ");
|
||||||
strcat(buf, data);
|
strcat(buf, data);
|
||||||
MQTT_DATA_SEND_STRUCT DSS;
|
MQTT_DATA_SEND_STRUCT DSS = {0};
|
||||||
ComposeTopic(DSS.topic, idx, "LOG", "UPLINK");
|
ComposeTopic(DSS.topic, idx, "LOG", "UPLINK");
|
||||||
DSS.raw_data_ptr = buf;
|
DSS.raw_data_ptr = buf;
|
||||||
DSS.data_length = strlen(buf);
|
DSS.data_length = strlen(buf);
|
||||||
|
DSS.keep_memory_onfinish = false;
|
||||||
if (xQueueSend(GetMQTTHandlesPool(idx)->mqtt_queue, &DSS, pdMS_TO_TICKS(0)) != pdPASS)
|
if (xQueueSend(GetMQTTHandlesPool(idx)->mqtt_queue, &DSS, pdMS_TO_TICKS(0)) != pdPASS)
|
||||||
free(buf);
|
free(buf);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user