From 9b0365ab436debcc22b03490741d72b6e80a4ad8 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Mon, 10 Feb 2020 16:16:12 +0100 Subject: [PATCH] Fix logical error with zero dependencies in IsReachable() --- lib/icinga/checkable-dependency.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/icinga/checkable-dependency.cpp b/lib/icinga/checkable-dependency.cpp index 02ddfc12e..821c883a6 100644 --- a/lib/icinga/checkable-dependency.cpp +++ b/lib/icinga/checkable-dependency.cpp @@ -74,6 +74,7 @@ bool Checkable::IsReachable(DependencyType dt, Dependency::Ptr *failedDependency auto deps = GetDependencies(); + int countDeps = deps.size(); int countFailed = 0; for (const Dependency::Ptr& dep : deps) { @@ -85,7 +86,8 @@ bool Checkable::IsReachable(DependencyType dt, Dependency::Ptr *failedDependency } } - if (countFailed == deps.size()) { + /* If there are dependencies, and all of them failed, mark as unreachable. */ + if (countDeps > 0 && countFailed == countDeps) { Log(LogDebug, "Checkable") << "All dependencies have failed for checkable '" << GetName() << "': Marking as unreachable.";