mirror of https://github.com/Icinga/icinga2.git
Make sure the dependency graph is properly updated when adding and removing objects
fixes #11686 fixes #11374
This commit is contained in:
parent
9baa08d24a
commit
b8e911b0e5
|
@ -34,7 +34,20 @@ void DependencyGraph::AddDependency(Object *parent, Object *child)
|
|||
void DependencyGraph::RemoveDependency(Object *parent, Object *child)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_Mutex);
|
||||
m_Dependencies[child][parent]--;
|
||||
|
||||
std::map<Object *, int>& refs = m_Dependencies[child];
|
||||
std::map<Object *, int>::iterator it = refs.find(parent);
|
||||
|
||||
if (it == refs.end())
|
||||
return;
|
||||
|
||||
it->second--;
|
||||
|
||||
if (it->second == 0)
|
||||
refs.erase(it);
|
||||
|
||||
if (refs.empty())
|
||||
m_Dependencies.erase(child);
|
||||
}
|
||||
|
||||
std::vector<Object::Ptr> DependencyGraph::GetParents(const Object::Ptr& child)
|
||||
|
|
|
@ -67,7 +67,7 @@ class Comment : ConfigObject < CommentNameComposer
|
|||
|
||||
if (!newValue.IsEmpty()) {
|
||||
Service::Ptr service = Service::GetByNamePair(GetHostName(), newValue);
|
||||
DependencyGraph::RemoveDependency(this, service.get());
|
||||
DependencyGraph::AddDependency(this, service.get());
|
||||
}
|
||||
}}}
|
||||
navigate {{{
|
||||
|
|
|
@ -55,7 +55,7 @@ class Dependency : CustomVarObject < DependencyNameComposer
|
|||
|
||||
if (!newValue.IsEmpty()) {
|
||||
Service::Ptr service = Service::GetByNamePair(GetParentHostName(), newValue);
|
||||
DependencyGraph::RemoveDependency(this, service.get());
|
||||
DependencyGraph::AddDependency(this, service.get());
|
||||
}
|
||||
}}}
|
||||
navigate {{{
|
||||
|
@ -82,7 +82,7 @@ class Dependency : CustomVarObject < DependencyNameComposer
|
|||
|
||||
if (!newValue.IsEmpty()) {
|
||||
Service::Ptr service = Service::GetByNamePair(GetParentHostName(), newValue);
|
||||
DependencyGraph::RemoveDependency(this, service.get());
|
||||
DependencyGraph::AddDependency(this, service.get());
|
||||
}
|
||||
}}}
|
||||
navigate {{{
|
||||
|
|
|
@ -54,7 +54,7 @@ class Downtime : ConfigObject < DowntimeNameComposer
|
|||
|
||||
if (!newValue.IsEmpty()) {
|
||||
Service::Ptr service = Service::GetByNamePair(GetHostName(), newValue);
|
||||
DependencyGraph::RemoveDependency(this, service.get());
|
||||
DependencyGraph::AddDependency(this, service.get());
|
||||
}
|
||||
}}}
|
||||
navigate {{{
|
||||
|
|
|
@ -74,7 +74,7 @@ class Notification : CustomVarObject < NotificationNameComposer
|
|||
|
||||
if (!newValue.IsEmpty()) {
|
||||
Service::Ptr service = Service::GetByNamePair(GetHostName(), newValue);
|
||||
DependencyGraph::RemoveDependency(this, service.get());
|
||||
DependencyGraph::AddDependency(this, service.get());
|
||||
}
|
||||
}}}
|
||||
navigate {{{
|
||||
|
|
|
@ -53,7 +53,7 @@ class ScheduledDowntime : CustomVarObject < ScheduledDowntimeNameComposer
|
|||
|
||||
if (!newValue.IsEmpty()) {
|
||||
Service::Ptr service = Service::GetByNamePair(GetHostName(), newValue);
|
||||
DependencyGraph::RemoveDependency(this, service.get());
|
||||
DependencyGraph::AddDependency(this, service.get());
|
||||
}
|
||||
}}}
|
||||
navigate {{{
|
||||
|
|
|
@ -901,7 +901,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
|
|||
<< "\t" << klass.Parent << "::Start(runtimeCreated);" << std::endl << std::endl;
|
||||
|
||||
for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
|
||||
if (!(it->Type.IsName))
|
||||
if (!it->Type.IsName && it->TrackAccessor.empty())
|
||||
continue;
|
||||
|
||||
m_Impl << "\t" << "Track" << it->GetFriendlyName() << "(Empty, Get" << it->GetFriendlyName() << "());" << std::endl;
|
||||
|
@ -913,7 +913,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
|
|||
<< "\t" << klass.Parent << "::Stop(runtimeRemoved);" << std::endl << std::endl;
|
||||
|
||||
for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
|
||||
if (!(it->Type.IsName))
|
||||
if (!it->Type.IsName && it->TrackAccessor.empty())
|
||||
continue;
|
||||
|
||||
m_Impl << "\t" << "Track" << it->GetFriendlyName() << "(Get" << it->GetFriendlyName() << "(), Empty);" << std::endl;
|
||||
|
|
Loading…
Reference in New Issue