diff --git a/subscriptionstore.cpp b/subscriptionstore.cpp index a5e85b0..73a3487 100644 --- a/subscriptionstore.cpp +++ b/subscriptionstore.cpp @@ -661,6 +661,8 @@ void SubscriptionStore::removeExpiredSessionsClients() logger->logf(LOG_DEBUG, "Cleaning out old sessions"); const std::chrono::time_point now = std::chrono::steady_clock::now(); + const std::chrono::seconds secondsSinceEpoch = std::chrono::duration_cast(now.time_since_epoch()); + int removedSessions = 0; int processedRemovals = 0; int queuedRemovalsLeft = -1; @@ -673,9 +675,9 @@ void SubscriptionStore::removeExpiredSessionsClients() auto it = queuedSessionRemovals.begin(); while (it != queuedSessionRemovals.end()) { - const std::chrono::time_point &removeAt = it->first; + const std::chrono::seconds &removeAt = it->first; - if (removeAt > now) + if (removeAt > secondsSinceEpoch) { break; } @@ -725,10 +727,11 @@ void SubscriptionStore::queueSessionRemoval(const std::shared_ptr &sess return; std::chrono::time_point removeAt = std::chrono::steady_clock::now() + std::chrono::seconds(session->getSessionExpiryInterval()); + std::chrono::seconds secondsSinceEpoch = std::chrono::duration_cast(removeAt.time_since_epoch()); session->setQueuedRemovalAt(); std::lock_guard locker(this->queuedSessionRemovalsMutex); - queuedSessionRemovals[removeAt].push_back(session); + queuedSessionRemovals[secondsSinceEpoch].push_back(session); } int64_t SubscriptionStore::getRetainedMessageCount() const diff --git a/subscriptionstore.h b/subscriptionstore.h index 0ce5651..99ad238 100644 --- a/subscriptionstore.h +++ b/subscriptionstore.h @@ -111,7 +111,7 @@ class SubscriptionStore const std::unordered_map> &sessionsByIdConst; std::mutex queuedSessionRemovalsMutex; - std::map, std::vector>> queuedSessionRemovals; + std::map>> queuedSessionRemovals; pthread_rwlock_t retainedMessagesRwlock = PTHREAD_RWLOCK_INITIALIZER; RetainedMessageNode retainedMessagesRoot;