ConfigObject#OnAllConfigLoaded(): build m_AllParentsAffectingLogging cache

recursively from ConfigObject#GetParentsAffectingLogging().
This commit is contained in:
Alexander A. Klimov 2023-08-15 11:17:40 +02:00
parent f98b5c5d7c
commit a3a6a8ab21
2 changed files with 14 additions and 0 deletions

View File

@ -419,6 +419,18 @@ void ConfigObject::OnAllConfigLoaded()
if (!zoneName.IsEmpty())
m_Zone = ctype->GetObject(zoneName);
std::vector<Ptr> 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)

View File

@ -9,6 +9,7 @@
#include "base/type.hpp"
#include "base/dictionary.hpp"
#include <boost/signals2.hpp>
#include <set>
namespace icinga
{
@ -81,6 +82,7 @@ public:
private:
ConfigObject::Ptr m_Zone;
std::set<ConfigObject*> m_AllParentsAffectingLogging;
static void RestoreObject(const String& message, int attributeTypes);
};