Commit 71ffc7d50de6dba13c6860afd93dc405583d35d5

Authored by Wiebe Cazemier
Committed by Wiebe Cazemier
1 parent 20b1d0a0

Fix broken lock guards

Showing 1 changed file with 4 additions and 4 deletions
subscriptionstore.cpp
@@ -300,7 +300,7 @@ std::shared_ptr<Session> SubscriptionStore::lockSession(const std::string &clien @@ -300,7 +300,7 @@ std::shared_ptr<Session> SubscriptionStore::lockSession(const std::string &clien
300 void SubscriptionStore::sendQueuedWillMessages() 300 void SubscriptionStore::sendQueuedWillMessages()
301 { 301 {
302 const auto now = std::chrono::steady_clock::now(); 302 const auto now = std::chrono::steady_clock::now();
303 - std::lock_guard<std::mutex>(this->pendingWillsMutex); 303 + std::lock_guard<std::mutex> locker(this->pendingWillsMutex);
304 304
305 auto it = pendingWillMessages.begin(); 305 auto it = pendingWillMessages.begin();
306 while (it != pendingWillMessages.end()) 306 while (it != pendingWillMessages.end())
@@ -366,7 +366,7 @@ void SubscriptionStore::queueWillMessage(const std::shared_ptr&lt;WillPublish&gt; &amp;wil @@ -366,7 +366,7 @@ void SubscriptionStore::queueWillMessage(const std::shared_ptr&lt;WillPublish&gt; &amp;wil
366 366
367 QueuedWill queuedWill(willMessage, session); 367 QueuedWill queuedWill(willMessage, session);
368 368
369 - std::lock_guard<std::mutex>(this->pendingWillsMutex); 369 + std::lock_guard<std::mutex> locker(this->pendingWillsMutex);
370 auto pos = std::upper_bound(this->pendingWillMessages.begin(), this->pendingWillMessages.end(), willMessage, willDelayCompare); 370 auto pos = std::upper_bound(this->pendingWillMessages.begin(), this->pendingWillMessages.end(), willMessage, willDelayCompare);
371 this->pendingWillMessages.insert(pos, queuedWill); 371 this->pendingWillMessages.insert(pos, queuedWill);
372 } 372 }
@@ -659,7 +659,7 @@ void SubscriptionStore::removeExpiredSessionsClients() @@ -659,7 +659,7 @@ void SubscriptionStore::removeExpiredSessionsClients()
659 int queuedRemovalsLeft = -1; 659 int queuedRemovalsLeft = -1;
660 660
661 { 661 {
662 - std::lock_guard<std::mutex>(this->queuedSessionRemovalsMutex); 662 + std::lock_guard<std::mutex> locker(this->queuedSessionRemovalsMutex);
663 663
664 queuedRemovalsLeft = queuedSessionRemovals.size(); 664 queuedRemovalsLeft = queuedSessionRemovals.size();
665 665
@@ -720,7 +720,7 @@ void SubscriptionStore::queueSessionRemoval(const std::shared_ptr&lt;Session&gt; &amp;sess @@ -720,7 +720,7 @@ void SubscriptionStore::queueSessionRemoval(const std::shared_ptr&lt;Session&gt; &amp;sess
720 std::chrono::time_point<std::chrono::steady_clock> removeAt = std::chrono::steady_clock::now() + std::chrono::seconds(session->getSessionExpiryInterval()); 720 std::chrono::time_point<std::chrono::steady_clock> removeAt = std::chrono::steady_clock::now() + std::chrono::seconds(session->getSessionExpiryInterval());
721 session->setQueuedRemovalAt(); 721 session->setQueuedRemovalAt();
722 722
723 - std::lock_guard<std::mutex>(this->queuedSessionRemovalsMutex); 723 + std::lock_guard<std::mutex> locker(this->queuedSessionRemovalsMutex);
724 queuedSessionRemovals[removeAt].push_back(session); 724 queuedSessionRemovals[removeAt].push_back(session);
725 } 725 }
726 726