diff --git a/subscriptionstore.cpp b/subscriptionstore.cpp index 73a3487..7e5a9d8 100644 --- a/subscriptionstore.cpp +++ b/subscriptionstore.cpp @@ -298,14 +298,15 @@ std::shared_ptr SubscriptionStore::lockSession(const std::string &clien void SubscriptionStore::sendQueuedWillMessages() { const auto now = std::chrono::steady_clock::now(); + const std::chrono::seconds secondsSinceEpoch = std::chrono::duration_cast(now.time_since_epoch()); std::lock_guard locker(this->pendingWillsMutex); auto it = pendingWillMessages.begin(); while (it != pendingWillMessages.end()) { - const std::chrono::time_point &sendAt = it->first; + const std::chrono::seconds &sendAt = it->first; - if (sendAt > now) + if (sendAt > secondsSinceEpoch) break; std::vector &willsOfSlot = it->second; @@ -373,9 +374,10 @@ void SubscriptionStore::queueWillMessage(const std::shared_ptr &wil QueuedWill queuedWill(willMessage, session); const std::chrono::time_point sendWillAt = std::chrono::steady_clock::now() + std::chrono::seconds(willMessage->will_delay); + std::chrono::seconds secondsSinceEpoch = std::chrono::duration_cast(sendWillAt.time_since_epoch()); std::lock_guard locker(this->pendingWillsMutex); - this->pendingWillMessages[sendWillAt].push_back(queuedWill); + this->pendingWillMessages[secondsSinceEpoch].push_back(queuedWill); } void SubscriptionStore::publishNonRecursively(const std::unordered_map &subscribers, diff --git a/subscriptionstore.h b/subscriptionstore.h index 99ad238..64b7136 100644 --- a/subscriptionstore.h +++ b/subscriptionstore.h @@ -119,7 +119,7 @@ class SubscriptionStore int64_t retainedMessageCount = 0; std::mutex pendingWillsMutex; - std::map, std::vector> pendingWillMessages; + std::map> pendingWillMessages; std::chrono::time_point lastTreeCleanup;