diff options
Diffstat (limited to 'src/mongo/db/keys_collection_manager.cpp')
-rw-r--r-- | src/mongo/db/keys_collection_manager.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/mongo/db/keys_collection_manager.cpp b/src/mongo/db/keys_collection_manager.cpp index 87f02b68e64..8b40033705f 100644 --- a/src/mongo/db/keys_collection_manager.cpp +++ b/src/mongo/db/keys_collection_manager.cpp @@ -223,6 +223,8 @@ void KeysCollectionManager::PeriodicRunner::_doPeriodicRefresh(ServiceContext* s Milliseconds refreshInterval) { ThreadClient tc(threadName, service); + ON_BLOCK_EXIT([this]() mutable { _hasSeenKeys.store(false); }); + while (true) { unsigned errorCount = 0; @@ -251,10 +253,7 @@ void KeysCollectionManager::PeriodicRunner::_doPeriodicRefresh(ServiceContext* s const auto& latestKey = latestKeyStatusWith.getValue(); auto currentTime = LogicalClock::get(service)->getClusterTime(); - { - stdx::unique_lock<Latch> lock(_mutex); - _hasSeenKeys = true; - } + _hasSeenKeys.store(true); nextWakeup = howMuchSleepNeedFor(currentTime, latestKey.getExpiresAt(), refreshInterval); @@ -345,16 +344,14 @@ void KeysCollectionManager::PeriodicRunner::stop() { } _inShutdown = true; - _hasSeenKeys = false; _refreshNeededCV.notify_all(); } _backgroundThread.join(); } -bool KeysCollectionManager::PeriodicRunner::hasSeenKeys() { - stdx::lock_guard<Latch> lock(_mutex); - return _hasSeenKeys; +bool KeysCollectionManager::PeriodicRunner::hasSeenKeys() const noexcept { + return _hasSeenKeys.load(); } } // namespace mongo |