summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-01-14 10:56:50 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-01-14 21:04:10 +0100
commita2eaf99e46f370ffb3b73828c2bdc53dc193b9a4 (patch)
tree6d08d7b5077478a92acde6dd6e7278e98a409ce1 /svl
parent49a5e69f567302633299bf6626a9d9b9544ee94b (diff)
make comphelper::OInterfaceContainerHelper4 more threadsafe
(*) make all the methods that require an external mutex take a std::unique_lock as a parameter, so that call sites cannot forget (*) make the forEach method drop the lock when firing listener methods, to reduce the odds of deadlock Change-Id: I0a80e3b3d1c1c03b7de4a658d31fcc2847690903 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128415 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/fsstor/oinputstreamcontainer.cxx8
-rw-r--r--svl/source/fsstor/ostreamcontainer.cxx8
2 files changed, 8 insertions, 8 deletions
diff --git a/svl/source/fsstor/oinputstreamcontainer.cxx b/svl/source/fsstor/oinputstreamcontainer.cxx
index 1339096dce9f..a2dc0456a84c 100644
--- a/svl/source/fsstor/oinputstreamcontainer.cxx
+++ b/svl/source/fsstor/oinputstreamcontainer.cxx
@@ -239,22 +239,22 @@ void SAL_CALL OFSInputStreamContainer::dispose( )
void SAL_CALL OFSInputStreamContainer::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
{
- std::scoped_lock aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
if ( m_bDisposed )
throw lang::DisposedException();
- m_aListenersContainer.addInterface( xListener );
+ m_aListenersContainer.addInterface( aGuard, xListener );
}
void SAL_CALL OFSInputStreamContainer::removeEventListener( const uno::Reference< lang::XEventListener >& xListener )
{
- std::scoped_lock aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
if ( m_bDisposed )
throw lang::DisposedException();
- m_aListenersContainer.removeInterface( xListener );
+ m_aListenersContainer.removeInterface( aGuard, xListener );
}
diff --git a/svl/source/fsstor/ostreamcontainer.cxx b/svl/source/fsstor/ostreamcontainer.cxx
index bfa6962ee9c4..d8ef930f7e98 100644
--- a/svl/source/fsstor/ostreamcontainer.cxx
+++ b/svl/source/fsstor/ostreamcontainer.cxx
@@ -233,22 +233,22 @@ void SAL_CALL OFSStreamContainer::dispose()
void SAL_CALL OFSStreamContainer::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
{
- std::scoped_lock aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
if ( m_bDisposed )
throw lang::DisposedException();
- m_aListenersContainer.addInterface( xListener );
+ m_aListenersContainer.addInterface( aGuard, xListener );
}
void SAL_CALL OFSStreamContainer::removeEventListener( const uno::Reference< lang::XEventListener >& xListener )
{
- std::scoped_lock aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
if ( m_bDisposed )
throw lang::DisposedException();
- m_aListenersContainer.removeInterface( xListener );
+ m_aListenersContainer.removeInterface( aGuard, xListener );
}