mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-19 19:54:34 +02:00
Fixed invalid iterator use.
This commit is contained in:
parent
d8be3f088f
commit
2f7b67ce2b
@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
map<pair<String, String>, Dictionary::Ptr> DynamicObject::m_PersistentUpdates;
|
|
||||||
double DynamicObject::m_CurrentTx = 0;
|
double DynamicObject::m_CurrentTx = 0;
|
||||||
set<DynamicObject::Ptr> DynamicObject::m_ModifiedObjects;
|
set<DynamicObject::Ptr> DynamicObject::m_ModifiedObjects;
|
||||||
|
|
||||||
@ -442,7 +441,7 @@ void DynamicObject::RestoreObjects(const String& filename)
|
|||||||
} else {
|
} else {
|
||||||
/* keep non-replicated objects until another config object with
|
/* keep non-replicated objects until another config object with
|
||||||
* the same name is created (which is when we restore its tags) */
|
* the same name is created (which is when we restore its tags) */
|
||||||
m_PersistentUpdates[make_pair(type, name)] = update;
|
GetPersistentObjects()[make_pair(type, name)] = update;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -459,6 +458,13 @@ DynamicObject::ClassMap& DynamicObject::GetClasses(void)
|
|||||||
return classes;
|
return classes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DynamicObject::PersistentUpdateMap& DynamicObject::GetPersistentObjects(void)
|
||||||
|
{
|
||||||
|
static DynamicObject::PersistentUpdateMap persistentObjects;
|
||||||
|
return persistentObjects;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DynamicObject::RegisterClass(const String& type, DynamicObject::Factory factory)
|
void DynamicObject::RegisterClass(const String& type, DynamicObject::Factory factory)
|
||||||
{
|
{
|
||||||
if (GetObjects(type).first != GetObjects(type).second)
|
if (GetObjects(type).first != GetObjects(type).second)
|
||||||
@ -469,7 +475,7 @@ void DynamicObject::RegisterClass(const String& type, DynamicObject::Factory fac
|
|||||||
|
|
||||||
/* restore persistent objects that match the newly-registered class */
|
/* restore persistent objects that match the newly-registered class */
|
||||||
map<pair<String, String>, Dictionary::Ptr>::iterator prev, st;
|
map<pair<String, String>, Dictionary::Ptr>::iterator prev, st;
|
||||||
for (st = m_PersistentUpdates.begin(); st != m_PersistentUpdates.end(); st++)
|
for (st = GetPersistentObjects().begin(); st != GetPersistentObjects().end(); )
|
||||||
{
|
{
|
||||||
/* check type of the update */
|
/* check type of the update */
|
||||||
if (st->first.first != type) {
|
if (st->first.first != type) {
|
||||||
@ -489,7 +495,7 @@ void DynamicObject::RegisterClass(const String& type, DynamicObject::Factory fac
|
|||||||
|
|
||||||
prev = st;
|
prev = st;
|
||||||
st++;
|
st++;
|
||||||
m_PersistentUpdates.erase(prev);
|
GetPersistentObjects().erase(prev);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -515,14 +521,14 @@ DynamicObject::Ptr DynamicObject::Create(const String& type, const Dictionary::P
|
|||||||
|
|
||||||
/* restore the object's persistent non-config attributes */
|
/* restore the object's persistent non-config attributes */
|
||||||
map<pair<String, String>, Dictionary::Ptr>::iterator st;
|
map<pair<String, String>, Dictionary::Ptr>::iterator st;
|
||||||
st = m_PersistentUpdates.find(make_pair(obj->GetType(), obj->GetName()));
|
st = GetPersistentObjects().find(make_pair(obj->GetType(), obj->GetName()));
|
||||||
if (st != m_PersistentUpdates.end()) {
|
if (st != GetPersistentObjects().end()) {
|
||||||
Logger::Write(LogDebug, "base", "Restoring persistent state "
|
Logger::Write(LogDebug, "base", "Restoring persistent state "
|
||||||
"for object " + obj->GetType() + ":" + obj->GetName());
|
"for object " + obj->GetType() + ":" + obj->GetName());
|
||||||
obj->ApplyUpdate(st->second, Attribute_All & ~Attribute_Config);
|
obj->ApplyUpdate(st->second, Attribute_All & ~Attribute_Config);
|
||||||
|
|
||||||
/* we're done with this update, remove it */
|
/* we're done with this update, remove it */
|
||||||
m_PersistentUpdates.erase(st);
|
GetPersistentObjects().erase(st);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* apply the object's non-config attributes */
|
/* apply the object's non-config attributes */
|
||||||
|
@ -138,9 +138,11 @@ private:
|
|||||||
AttributeMap m_Attributes;
|
AttributeMap m_Attributes;
|
||||||
double m_ConfigTx;
|
double m_ConfigTx;
|
||||||
|
|
||||||
static map<pair<String, String>, Dictionary::Ptr> m_PersistentUpdates;
|
|
||||||
static double m_CurrentTx;
|
static double m_CurrentTx;
|
||||||
|
|
||||||
|
typedef map<pair<String, String>, Dictionary::Ptr> PersistentUpdateMap;
|
||||||
|
static PersistentUpdateMap& GetPersistentObjects(void);
|
||||||
|
|
||||||
static set<DynamicObject::Ptr> m_ModifiedObjects;
|
static set<DynamicObject::Ptr> m_ModifiedObjects;
|
||||||
|
|
||||||
void InternalApplyUpdate(const Dictionary::Ptr& serializedUpdate, int allowedTypes, bool suppressEvents);
|
void InternalApplyUpdate(const Dictionary::Ptr& serializedUpdate, int allowedTypes, bool suppressEvents);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user