Fix deadlock in DB IDO and external command events

refs #8511
This commit is contained in:
Michael Friedrich 2015-03-02 16:20:22 +01:00
parent 97ff17eb4e
commit c61134d55a
2 changed files with 11 additions and 5 deletions

View File

@ -293,6 +293,8 @@ void DbObject::OnStatusUpdate(void)
DbObject::Ptr DbObject::GetOrCreateByObject(const DynamicObject::Ptr& object)
{
boost::mutex::scoped_lock lock(GetStaticMutex());
DbObject::Ptr dbobj = object->GetExtension("DbObject");
if (dbobj)
@ -326,11 +328,8 @@ DbObject::Ptr DbObject::GetOrCreateByObject(const DynamicObject::Ptr& object)
dbobj = dbtype->GetOrCreateObjectByName(name1, name2);
{
ObjectLock olock(object);
dbobj->SetObject(object);
object->SetExtension("DbObject", dbobj);
}
dbobj->SetObject(object);
object->SetExtension("DbObject", dbobj);
return dbobj;
}
@ -357,3 +356,9 @@ void DbObject::VarsChangedHandler(const CustomVarObject::Ptr& object)
dbobj->SendVarsStatusUpdate();
}
boost::mutex& DbObject::GetStaticMutex(void)
{
static boost::mutex mutex;
return mutex;
}

View File

@ -105,6 +105,7 @@ private:
static void StateChangedHandler(const DynamicObject::Ptr& object);
static void VarsChangedHandler(const CustomVarObject::Ptr& object);
static boost::mutex& GetStaticMutex(void);
friend class DbType;
};