mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-26 15:14:07 +02:00
Detect local time changes.
This commit is contained in:
parent
8c491cb545
commit
c81fd071e6
@ -99,6 +99,8 @@ void Application::RunEventLoop(void)
|
|||||||
double nextProfile = 0;
|
double nextProfile = 0;
|
||||||
#endif /* _DEBUG */
|
#endif /* _DEBUG */
|
||||||
|
|
||||||
|
double lastLoop = Utility::GetTime();
|
||||||
|
|
||||||
while (!m_ShuttingDown) {
|
while (!m_ShuttingDown) {
|
||||||
Object::ClearHeldObjects();
|
Object::ClearHeldObjects();
|
||||||
|
|
||||||
@ -123,6 +125,20 @@ void Application::RunEventLoop(void)
|
|||||||
nextProfile = Utility::GetTime() + 15.0;
|
nextProfile = Utility::GetTime() + 15.0;
|
||||||
}
|
}
|
||||||
#endif /* _DEBUG */
|
#endif /* _DEBUG */
|
||||||
|
|
||||||
|
double now = Utility::GetTime();
|
||||||
|
|
||||||
|
if (now < lastLoop) {
|
||||||
|
/* We moved backwards in time - cool. */
|
||||||
|
double lostTime = lastLoop - now;
|
||||||
|
stringstream msgbuf;
|
||||||
|
msgbuf << "We moved backwards in time: " << lostTime
|
||||||
|
<< " seconds";
|
||||||
|
Logger::Write(LogInformation, "base", msgbuf.str());
|
||||||
|
Timer::AdjustTimers(-lostTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
lastLoop = now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,3 +155,16 @@ void Timer::Reschedule(double next)
|
|||||||
{
|
{
|
||||||
m_Next = next;
|
m_Next = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adjusts all timers by adding the specified amount of time to their
|
||||||
|
* next scheduled timestamp.
|
||||||
|
*
|
||||||
|
* @param adjustment The adjustment.
|
||||||
|
*/
|
||||||
|
void Timer::AdjustTimers(double adjustment)
|
||||||
|
{
|
||||||
|
BOOST_FOREACH(Timer::Ptr timer, m_Timers) {
|
||||||
|
timer->m_Next += adjustment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -43,6 +43,7 @@ public:
|
|||||||
double GetInterval(void) const;
|
double GetInterval(void) const;
|
||||||
|
|
||||||
static double ProcessTimers(void);
|
static double ProcessTimers(void);
|
||||||
|
static void AdjustTimers(double adjustment);
|
||||||
|
|
||||||
void Start(void);
|
void Start(void);
|
||||||
void Stop(void);
|
void Stop(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user