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) {