mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
Better detect debugger attached in watchdog
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user