Better detect debugger attached in watchdog

This commit is contained in:
Klaus Basan
2018-06-20 00:54:20 +02:00
parent fc1a2bbb0f
commit b0c54b4a9f
2 changed files with 11 additions and 3 deletions

View File

@@ -148,14 +148,21 @@ namespace BlackCore
void CAirspaceAnalyzer::watchdogCheckTimeouts()
{
// this is a trick to not remove everything while debugging
const qint64 currentTimeMsEpoch = QDateTime::currentMSecsSinceEpoch();
const qint64 callDiffMs = currentTimeMsEpoch - m_lastWatchdogCallMsSinceEpoch;
const qint64 callThresholdMs = static_cast<qint64>(m_updateTimer.interval() * 1.5);
m_lastWatchdogCallMsSinceEpoch = currentTimeMsEpoch;
if (callDiffMs > callThresholdMs)
{
// allow some time to normalize before checking again
m_doNotRunAgainBefore = currentTimeMsEpoch + 2 * callThresholdMs;
return;
}
if (m_doNotRunAgainBefore > currentTimeMsEpoch) { return; }
m_doNotRunAgainBefore = -1;
// this is a trick to not remove everything while debugging
if (callDiffMs > callThresholdMs) { return; }
// checks
const qint64 aircraftTimeoutMs = m_timeoutAircraft.valueInteger(CTimeUnit::ms());
const qint64 atcTimeoutMs = m_timeoutAtc.valueInteger(CTimeUnit::ms());
const qint64 timeoutAircraftEpochMs = currentTimeMsEpoch - aircraftTimeoutMs;

View File

@@ -130,6 +130,7 @@ namespace BlackCore
BlackMisc::PhysicalQuantities::CTime m_timeoutAircraft = { 15, BlackMisc::PhysicalQuantities::CTimeUnit::s() }; //!< Timeout value for watchdog functionality
BlackMisc::PhysicalQuantities::CTime m_timeoutAtc = { 50, BlackMisc::PhysicalQuantities::CTimeUnit::s() }; //!< Timeout value for watchdog functionality
qint64 m_lastWatchdogCallMsSinceEpoch; //!< when last called
qint64 m_doNotRunAgainBefore = -1; //!< do not run again before, also used to detect debugging
std::atomic_bool m_enabledWatchdog { true }; //!< watchdog enabled
// snapshot