Skip to content

Commit

Permalink
ConfigObject#OnAllConfigLoaded(): build m_AllParentsAffectingLogging …
Browse files Browse the repository at this point in the history
…cache

recursively from ConfigObject#GetParentsAffectingLogging().
  • Loading branch information
Al2Klimov committed Aug 15, 2023
1 parent aff9687 commit 7f917b0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/base/configobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions lib/base/configobject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "base/type.hpp"
#include "base/dictionary.hpp"
#include <boost/signals2.hpp>
#include <set>

namespace icinga
{
Expand Down Expand Up @@ -81,6 +82,7 @@ class ConfigObject : public ObjectImpl<ConfigObject>

private:
ConfigObject::Ptr m_Zone;
std::set<ConfigObject*> m_AllParentsAffectingLogging;

static void RestoreObject(const String& message, int attributeTypes);
};
Expand Down

0 comments on commit 7f917b0

Please sign in to comment.