diff --git a/lib/base/dependencygraph.cpp b/lib/base/dependencygraph.cpp index 6f1053c88..037830d56 100644 --- a/lib/base/dependencygraph.cpp +++ b/lib/base/dependencygraph.cpp @@ -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& refs = m_Dependencies[child]; + std::map::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 DependencyGraph::GetParents(const Object::Ptr& child) diff --git a/lib/icinga/comment.ti b/lib/icinga/comment.ti index 8ac497aac..94ad48ebb 100644 --- a/lib/icinga/comment.ti +++ b/lib/icinga/comment.ti @@ -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 {{{ diff --git a/lib/icinga/dependency.ti b/lib/icinga/dependency.ti index aeb943fc7..fbbb8246c 100644 --- a/lib/icinga/dependency.ti +++ b/lib/icinga/dependency.ti @@ -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 {{{ diff --git a/lib/icinga/downtime.ti b/lib/icinga/downtime.ti index d5a16988a..5c7a19bdd 100644 --- a/lib/icinga/downtime.ti +++ b/lib/icinga/downtime.ti @@ -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 {{{ diff --git a/lib/icinga/notification.ti b/lib/icinga/notification.ti index c8825b31a..18604e2e9 100644 --- a/lib/icinga/notification.ti +++ b/lib/icinga/notification.ti @@ -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 {{{ diff --git a/lib/icinga/scheduleddowntime.ti b/lib/icinga/scheduleddowntime.ti index 4b95ae60c..92b5e4659 100644 --- a/lib/icinga/scheduleddowntime.ti +++ b/lib/icinga/scheduleddowntime.ti @@ -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 {{{ diff --git a/tools/mkclass/classcompiler.cpp b/tools/mkclass/classcompiler.cpp index 60ae196c7..b72cd76d4 100644 --- a/tools/mkclass/classcompiler.cpp +++ b/tools/mkclass/classcompiler.cpp @@ -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;