From 2a14803897ab3eef9f53c28cd19d0c17c1020d02 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 15 Aug 2023 11:17:40 +0200 Subject: [PATCH] ConfigObject#OnAllConfigLoaded(): build m_AllParentsAffectingLogging cache recursively from ConfigObject#GetParentsAffectingLogging(). --- lib/base/configobject.cpp | 12 ++++++++++++ lib/base/configobject.hpp | 2 ++ 2 files changed, 14 insertions(+) diff --git a/lib/base/configobject.cpp b/lib/base/configobject.cpp index 4317771d1f8..fee6e43743c 100644 --- a/lib/base/configobject.cpp +++ b/lib/base/configobject.cpp @@ -419,6 +419,18 @@ void ConfigObject::OnAllConfigLoaded() if (!zoneName.IsEmpty()) m_Zone = ctype->GetObject(zoneName); + + std::vector toDo {this}; + + do { + auto current (toDo.back()); + + toDo.pop_back(); + + if (m_AllParentsAffectingLogging.emplace(current.get()).second) { + current->GetParentsAffectingLogging(toDo); + } + } while (!toDo.empty()); } void ConfigObject::CreateChildObjects(const Type::Ptr& childType) diff --git a/lib/base/configobject.hpp b/lib/base/configobject.hpp index 5596363703c..a091c0a3a8c 100644 --- a/lib/base/configobject.hpp +++ b/lib/base/configobject.hpp @@ -9,6 +9,7 @@ #include "base/type.hpp" #include "base/dictionary.hpp" #include +#include namespace icinga { @@ -81,6 +82,7 @@ class ConfigObject : public ObjectImpl private: ConfigObject::Ptr m_Zone; + std::set m_AllParentsAffectingLogging; static void RestoreObject(const String& message, int attributeTypes); };