From 2c4500f27ef16b00e5944085dd637788472173fc Mon Sep 17 00:00:00 2001 From: Wiebe Cazemier Date: Sun, 17 Nov 2024 22:41:24 +0100 Subject: [PATCH] Also reuse publish between MQTT3.1 and MQTT 3.1.1 publisher/subscriber This is essentially a fixup of a commit 6373657657. --- FlashMQTests/tst_maintests.cpp | 2 +- publishcopyfactory.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/FlashMQTests/tst_maintests.cpp b/FlashMQTests/tst_maintests.cpp index ac4d445..20a94fb 100644 --- a/FlashMQTests/tst_maintests.cpp +++ b/FlashMQTests/tst_maintests.cpp @@ -1221,7 +1221,7 @@ void MainTests::testbufferToMqttPacketsFuzz() void testDowngradeQoSOnSubscribeHelper(const uint8_t pub_qos, const uint8_t sub_qos) { - std::vector protocols {ProtocolVersion::Mqtt311, ProtocolVersion::Mqtt5}; + std::vector protocols {ProtocolVersion::Mqtt31, ProtocolVersion::Mqtt311, ProtocolVersion::Mqtt5}; for (const ProtocolVersion senderVersion : protocols) { diff --git a/publishcopyfactory.cpp b/publishcopyfactory.cpp index 874abfb..7c6a354 100644 --- a/publishcopyfactory.cpp +++ b/publishcopyfactory.cpp @@ -59,7 +59,7 @@ MqttPacket *PublishCopyFactory::getOptimumPacket( // Note that this cache also possibly contains the expiration interval, but because we're only hitting this block for on-line // publishers, the interval has not decreased and is fine. - const int cache_key = (static_cast(protocolVersion) * 10) + static_cast(actualQos); + const int cache_key = (getPublishLayoutCompareKey(protocolVersion) * 10) + static_cast(actualQos); std::optional &cachedPack = constructedPacketCache[cache_key]; if (!cachedPack)