diff --git a/lib/espMqttClient/src/MqttClient.h b/lib/espMqttClient/src/MqttClient.h index a357c5779..6cf8d0664 100644 --- a/lib/espMqttClient/src/MqttClient.h +++ b/lib/espMqttClient/src/MqttClient.h @@ -131,10 +131,9 @@ class MqttClient { uint32_t timeSent; espMqttClientInternals::Packet packet; template - OutgoingPacket(uint32_t t, espMqttClientTypes::Error & error, Args &&... args) - : timeSent(t) - , packet(error, std::forward(args)...) { - } + OutgoingPacket(uint32_t t, espMqttClientTypes::Error& error, Args&&... args) : // NOLINT(runtime/references) + timeSent(t), + packet(error, std::forward(args)...) {} }; espMqttClientInternals::Outbox _outbox; size_t _bytesSent; @@ -150,18 +149,26 @@ class MqttClient { bool _addPacket(Args &&... args) { espMqttClientTypes::Error error(espMqttClientTypes::Error::SUCCESS); espMqttClientInternals::Outbox::Iterator it = _outbox.emplace(0, error, std::forward(args)...); - if (it && error == espMqttClientTypes::Error::SUCCESS) + if (it && error == espMqttClientTypes::Error::SUCCESS) { return true; - return false; + } else { + if (it) + _outbox.remove(it); + return false; + } } template bool _addPacketFront(Args &&... args) { espMqttClientTypes::Error error(espMqttClientTypes::Error::SUCCESS); espMqttClientInternals::Outbox::Iterator it = _outbox.emplaceFront(0, error, std::forward(args)...); - if (it && error == espMqttClientTypes::Error::SUCCESS) + if (it && error == espMqttClientTypes::Error::SUCCESS) { return true; - return false; + } else { + if (it) + _outbox.remove(it); + return false; + } } void _checkOutbox(); diff --git a/src/version.h b/src/version.h index 69d734367..54c0226cd 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define EMSESP_APP_VERSION "3.7.0-dev.1d" +#define EMSESP_APP_VERSION "3.7.0-dev.2"