Skip to content

Commit 4b7f0a7

Browse files
committed
Checkable: Don't count duplicated child dependencies twice
1 parent 4db6e14 commit 4b7f0a7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/icinga/checkable-dependency.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,14 @@ int Checkable::GetAllChildrenCount(int rstack) const
173173
return 0;
174174
}
175175

176+
std::set<Checkable*> seenChildren; // To avoid false positives in case of duplicated dependencies.
176177
int count = 0;
177178
// Actually, incrementing the rstack should be done once outside the loop here, but since IsReachable()
178179
// applies the limit the exact same way, it should be fine to limit the sum of calls to 256 here as well.
179180
for (auto& dependency: GetReverseDependencies()) {
180-
count += dependency->GetChild()->GetAllChildrenCount(rstack + 1) + 1;
181+
if (auto child(dependency->GetChild()); seenChildren.insert(child.get()).second) {
182+
count += child->GetAllChildrenCount(rstack + 1) + 1;
183+
}
181184
}
182185

183186
return count;

0 commit comments

Comments
 (0)