Switch deadlock detector to steady_clock

* Changes to system time should not trigger the deadlock detector.
* Fixes #3101
This commit is contained in:
Howard Hinnant
2019-10-09 13:12:39 -04:00
committed by Manoj doshi
parent ca6d5798e9
commit 3f45b8c3bd
2 changed files with 7 additions and 4 deletions

View File

@@ -61,13 +61,14 @@ void LoadManager::activateDeadlockDetector ()
{
std::lock_guard sl (mutex_);
armed_ = true;
deadLock_ = std::chrono::steady_clock::now();
}
void LoadManager::resetDeadlockDetector ()
{
auto const elapsedSeconds = UptimeClock::now();
auto const detector_start = std::chrono::steady_clock::now();
std::lock_guard sl (mutex_);
deadLock_ = elapsedSeconds;
deadLock_ = detector_start;
}
//------------------------------------------------------------------------------
@@ -121,7 +122,9 @@ void LoadManager::run ()
sl.unlock();
// Measure the amount of time we have been deadlocked, in seconds.
auto const timeSpentDeadlocked = UptimeClock::now() - deadLock;
using namespace std::chrono;
auto const timeSpentDeadlocked =
duration_cast<seconds>(steady_clock::now() - deadLock);
auto const reportingIntervalSeconds = 10s;
if (armed && (timeSpentDeadlocked >= reportingIntervalSeconds))