mirror of https://github.com/Icinga/icinga2.git
parent
97ff17eb4e
commit
c61134d55a
|
@ -293,6 +293,8 @@ void DbObject::OnStatusUpdate(void)
|
||||||
|
|
||||||
DbObject::Ptr DbObject::GetOrCreateByObject(const DynamicObject::Ptr& object)
|
DbObject::Ptr DbObject::GetOrCreateByObject(const DynamicObject::Ptr& object)
|
||||||
{
|
{
|
||||||
|
boost::mutex::scoped_lock lock(GetStaticMutex());
|
||||||
|
|
||||||
DbObject::Ptr dbobj = object->GetExtension("DbObject");
|
DbObject::Ptr dbobj = object->GetExtension("DbObject");
|
||||||
|
|
||||||
if (dbobj)
|
if (dbobj)
|
||||||
|
@ -326,11 +328,8 @@ DbObject::Ptr DbObject::GetOrCreateByObject(const DynamicObject::Ptr& object)
|
||||||
|
|
||||||
dbobj = dbtype->GetOrCreateObjectByName(name1, name2);
|
dbobj = dbtype->GetOrCreateObjectByName(name1, name2);
|
||||||
|
|
||||||
{
|
|
||||||
ObjectLock olock(object);
|
|
||||||
dbobj->SetObject(object);
|
dbobj->SetObject(object);
|
||||||
object->SetExtension("DbObject", dbobj);
|
object->SetExtension("DbObject", dbobj);
|
||||||
}
|
|
||||||
|
|
||||||
return dbobj;
|
return dbobj;
|
||||||
}
|
}
|
||||||
|
@ -357,3 +356,9 @@ void DbObject::VarsChangedHandler(const CustomVarObject::Ptr& object)
|
||||||
|
|
||||||
dbobj->SendVarsStatusUpdate();
|
dbobj->SendVarsStatusUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boost::mutex& DbObject::GetStaticMutex(void)
|
||||||
|
{
|
||||||
|
static boost::mutex mutex;
|
||||||
|
return mutex;
|
||||||
|
}
|
||||||
|
|
|
@ -105,6 +105,7 @@ private:
|
||||||
|
|
||||||
static void StateChangedHandler(const DynamicObject::Ptr& object);
|
static void StateChangedHandler(const DynamicObject::Ptr& object);
|
||||||
static void VarsChangedHandler(const CustomVarObject::Ptr& object);
|
static void VarsChangedHandler(const CustomVarObject::Ptr& object);
|
||||||
|
static boost::mutex& GetStaticMutex(void);
|
||||||
|
|
||||||
friend class DbType;
|
friend class DbType;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue