Merge pull request #6899 from Icinga/bugfix/localtime-zero-windows

Log: Ensure not to pass negative values to localtime()
This commit is contained in:
Michael Friedrich 2019-01-24 10:58:43 +01:00 committed by GitHub
commit 6b7f651478
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -83,10 +83,11 @@ void Checkable::UpdateNextCheck(const MessageOrigin::Ptr& origin)
adj = std::min(0.5 + fmod(GetSchedulingOffset(), interval * 5) / 100.0, adj);
double nextCheck = now - adj + interval;
double lastCheck = GetLastCheck();
Log(LogDebug, "Checkable")
<< "Update checkable '" << GetName() << "' with check interval '" << GetCheckInterval()
<< "' from last check time at " << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S %z", GetLastCheck())
<< "' from last check time at " << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S %z", (lastCheck < 0 ? 0 : lastCheck))
<< " (" << GetLastCheck() << ") to next check time at " << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S %z", nextCheck) << "(" << nextCheck << ").";
SetNextCheck(nextCheck, false, origin);