mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-21 11:35:53 +00:00
Switch deadlock detector to steady_clock
* Changes to system time should not trigger the deadlock detector. * Fixes #3101
This commit is contained in:
committed by
Manoj doshi
parent
ca6d5798e9
commit
3f45b8c3bd
@@ -61,13 +61,14 @@ void LoadManager::activateDeadlockDetector ()
|
|||||||
{
|
{
|
||||||
std::lock_guard sl (mutex_);
|
std::lock_guard sl (mutex_);
|
||||||
armed_ = true;
|
armed_ = true;
|
||||||
|
deadLock_ = std::chrono::steady_clock::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadManager::resetDeadlockDetector ()
|
void LoadManager::resetDeadlockDetector ()
|
||||||
{
|
{
|
||||||
auto const elapsedSeconds = UptimeClock::now();
|
auto const detector_start = std::chrono::steady_clock::now();
|
||||||
std::lock_guard sl (mutex_);
|
std::lock_guard sl (mutex_);
|
||||||
deadLock_ = elapsedSeconds;
|
deadLock_ = detector_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@@ -121,7 +122,9 @@ void LoadManager::run ()
|
|||||||
sl.unlock();
|
sl.unlock();
|
||||||
|
|
||||||
// Measure the amount of time we have been deadlocked, in seconds.
|
// 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;
|
auto const reportingIntervalSeconds = 10s;
|
||||||
if (armed && (timeSpentDeadlocked >= reportingIntervalSeconds))
|
if (armed && (timeSpentDeadlocked >= reportingIntervalSeconds))
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ private:
|
|||||||
std::thread thread_;
|
std::thread thread_;
|
||||||
std::mutex mutex_; // Guards deadLock_, armed_, and stop_.
|
std::mutex mutex_; // Guards deadLock_, armed_, and stop_.
|
||||||
|
|
||||||
UptimeClock::time_point deadLock_; // Detect server deadlocks.
|
std::chrono::steady_clock::time_point deadLock_; // Detect server deadlocks.
|
||||||
bool armed_;
|
bool armed_;
|
||||||
bool stop_;
|
bool stop_;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user