From 57dadb7ede8c0132f162a9b2bf57e8f0e2a5282a Mon Sep 17 00:00:00 2001 From: Wiebe Cazemier Date: Wed, 11 May 2022 19:32:46 +0200 Subject: [PATCH] Expire retained messages --- subscriptionstore.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/subscriptionstore.cpp b/subscriptionstore.cpp index 65655ab..341e94b 100644 --- a/subscriptionstore.cpp +++ b/subscriptionstore.cpp @@ -479,10 +479,14 @@ void SubscriptionStore::giveClientRetainedMessagesRecursively(std::vectorretainedMessages) + auto pos = this_node->retainedMessages.begin(); + while (pos != this_node->retainedMessages.end()) { - // TODO: hmm, const stuff forces me/it to make copy - packetList.emplace_front(rm.publish); + auto cur = pos++; + if (cur->publish.hasExpired()) + this_node->retainedMessages.erase(cur); + else + packetList.emplace_front(cur->publish); // TODO: hmm, const stuff forces me/it to make copy } if (poundMode) { -- libgit2 0.21.4