Commit 57dadb7ede8c0132f162a9b2bf57e8f0e2a5282a
1 parent
17c71d06
Expire retained messages
Showing
1 changed file
with
7 additions
and
3 deletions
subscriptionstore.cpp
| @@ -479,10 +479,14 @@ void SubscriptionStore::giveClientRetainedMessagesRecursively(std::vector<std::s | @@ -479,10 +479,14 @@ void SubscriptionStore::giveClientRetainedMessagesRecursively(std::vector<std::s | ||
| 479 | { | 479 | { |
| 480 | if (cur_subtopic_it == end) | 480 | if (cur_subtopic_it == end) |
| 481 | { | 481 | { |
| 482 | - for(const RetainedMessage &rm : this_node->retainedMessages) | 482 | + auto pos = this_node->retainedMessages.begin(); |
| 483 | + while (pos != this_node->retainedMessages.end()) | ||
| 483 | { | 484 | { |
| 484 | - // TODO: hmm, const stuff forces me/it to make copy | ||
| 485 | - packetList.emplace_front(rm.publish); | 485 | + auto cur = pos++; |
| 486 | + if (cur->publish.hasExpired()) | ||
| 487 | + this_node->retainedMessages.erase(cur); | ||
| 488 | + else | ||
| 489 | + packetList.emplace_front(cur->publish); // TODO: hmm, const stuff forces me/it to make copy | ||
| 486 | } | 490 | } |
| 487 | if (poundMode) | 491 | if (poundMode) |
| 488 | { | 492 | { |