cid#1555986 Check of thread-shared field evades lock acquisition
and cid#1556190 Check of thread-shared field evades lock acquisition cid#1555295 Check of thread-shared field evades lock acquisition cid#1608596 Check of thread-shared field evades lock acquisition cid#1555236 Check of thread-shared field evades lock acquisition Double-checked locking pattern Change-Id: Id5cba26750bbd9c7e0248181f636ff653ada5654 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176739 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
This commit is contained in:
parent
b9464eadfc
commit
a1a3fd98dc
@ -97,7 +97,6 @@ static bool td_equals(typelib_TypeDescriptionReference const* pTDR1,
|
||||
static cppu::type_entry* getTypeEntries(cppu::class_data* cd)
|
||||
{
|
||||
cppu::type_entry* pEntries = cd->m_typeEntries;
|
||||
if (!cd->m_storedTypeRefs) // not inited?
|
||||
{
|
||||
static std::mutex aMutex;
|
||||
std::scoped_lock guard(aMutex);
|
||||
@ -122,14 +121,9 @@ static cppu::type_entry* getTypeEntries(cppu::class_data* cd)
|
||||
// ref is statically held by getCppuType()
|
||||
pEntry->m_type.typeRef = rType.getTypeLibType();
|
||||
}
|
||||
OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
|
||||
cd->m_storedTypeRefs = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
|
||||
}
|
||||
return pEntries;
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,6 @@ static bool td_equals(typelib_TypeDescriptionReference const* pTDR1,
|
||||
static cppu::type_entry* getTypeEntries(cppu::class_data* cd)
|
||||
{
|
||||
cppu::type_entry* pEntries = cd->m_typeEntries;
|
||||
if (!cd->m_storedTypeRefs) // not inited?
|
||||
{
|
||||
static std::mutex aMutex;
|
||||
std::scoped_lock guard(aMutex);
|
||||
@ -106,14 +105,9 @@ static cppu::type_entry* getTypeEntries(cppu::class_data* cd)
|
||||
// ref is statically held by getCppuType()
|
||||
pEntry->m_type.typeRef = rType.getTypeLibType();
|
||||
}
|
||||
OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
|
||||
cd->m_storedTypeRefs = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
|
||||
}
|
||||
return pEntries;
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,6 @@ static bool td_equals(
|
||||
static type_entry * getTypeEntries( class_data * cd )
|
||||
{
|
||||
type_entry * pEntries = cd->m_typeEntries;
|
||||
if (! cd->m_storedTypeRefs) // not inited?
|
||||
{
|
||||
static std::mutex aMutex;
|
||||
std::scoped_lock guard( aMutex );
|
||||
@ -86,14 +85,9 @@ static type_entry * getTypeEntries( class_data * cd )
|
||||
// ref is statically held by getCppuType()
|
||||
pEntry->m_type.typeRef = rType.getTypeLibType();
|
||||
}
|
||||
OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
|
||||
cd->m_storedTypeRefs = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
|
||||
}
|
||||
return pEntries;
|
||||
}
|
||||
|
||||
|
@ -254,16 +254,12 @@ OWeakObject::~OWeakObject() COVERITY_NOEXCEPT_FALSE
|
||||
// XWeak
|
||||
Reference< XAdapter > SAL_CALL OWeakObject::queryAdapter()
|
||||
{
|
||||
if (!m_pWeakConnectionPoint)
|
||||
std::scoped_lock aGuard( *gpWeakMutex );
|
||||
if( !m_pWeakConnectionPoint )
|
||||
{
|
||||
// only acquire mutex if member is not created
|
||||
std::scoped_lock aGuard( *gpWeakMutex );
|
||||
if( !m_pWeakConnectionPoint )
|
||||
{
|
||||
OWeakConnectionPoint * p = new OWeakConnectionPoint(this);
|
||||
p->acquire();
|
||||
m_pWeakConnectionPoint = p;
|
||||
}
|
||||
OWeakConnectionPoint * p = new OWeakConnectionPoint(this);
|
||||
p->acquire();
|
||||
m_pWeakConnectionPoint = p;
|
||||
}
|
||||
|
||||
return m_pWeakConnectionPoint;
|
||||
|
@ -112,14 +112,11 @@ template <class TYPE>
|
||||
::cppu::IPropertyArrayHelper* OPropertyArrayUsageHelper<TYPE>::getArrayHelper()
|
||||
{
|
||||
OSL_ENSURE(s_nRefCount, "OPropertyArrayUsageHelper::getArrayHelper : suspicious call : have a refcount of 0 !");
|
||||
std::unique_lock aGuard(theMutex());
|
||||
if (!s_pProps)
|
||||
{
|
||||
std::unique_lock aGuard(theMutex());
|
||||
if (!s_pProps)
|
||||
{
|
||||
s_pProps = createArrayHelper();
|
||||
OSL_ENSURE(s_pProps, "OPropertyArrayUsageHelper::getArrayHelper : createArrayHelper returned nonsense !");
|
||||
}
|
||||
s_pProps = createArrayHelper();
|
||||
OSL_ENSURE(s_pProps, "OPropertyArrayUsageHelper::getArrayHelper : createArrayHelper returned nonsense !");
|
||||
}
|
||||
return s_pProps;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user