From 5c8d04ba82bee1d1a6199b01022a01cd4cf409d2 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Thu, 4 Jul 2019 14:25:30 +0100 Subject: [PATCH] Free message if request queue is full --- Sming/Core/Network/MqttClient.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sming/Core/Network/MqttClient.cpp b/Sming/Core/Network/MqttClient.cpp index 28379d0daf..932b51cb96 100644 --- a/Sming/Core/Network/MqttClient.cpp +++ b/Sming/Core/Network/MqttClient.cpp @@ -225,6 +225,11 @@ bool MqttClient::connect(const Url& url, const String& clientName, uint32_t sslO } } + if(requestQueue.full()) { + debug_e("MQTT request queue full!"); + return false; + } + mqtt_message_t* message = (mqtt_message_t*)malloc(sizeof(mqtt_message_t)); memcpy(message, &connectMessage, sizeof(mqtt_message_t)); requestQueue.enqueue(message);