summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--comphelper/source/misc/solarmutex.cxx4
-rw-r--r--include/comphelper/solarmutex.hxx5
2 files changed, 6 insertions, 3 deletions
diff --git a/comphelper/source/misc/solarmutex.cxx b/comphelper/source/misc/solarmutex.cxx
index 3a6b34af1947..b9747dbac1b3 100644
--- a/comphelper/source/misc/solarmutex.cxx
+++ b/comphelper/source/misc/solarmutex.cxx
@@ -60,9 +60,9 @@ void SolarMutex::doAcquire( const sal_uInt32 nLockCount )
sal_uInt32 SolarMutex::doRelease( bool bUnlockAll )
{
- if ( m_nCount == 0 )
+ if ( !IsCurrentThread() )
std::abort();
- if ( m_nThreadId != osl::Thread::getCurrentIdentifier() )
+ if ( m_nCount == 0 )
std::abort();
const sal_uInt32 nCount = bUnlockAll ? m_nCount : 1;
diff --git a/include/comphelper/solarmutex.hxx b/include/comphelper/solarmutex.hxx
index 0c147f405560..4094e08ee1f7 100644
--- a/include/comphelper/solarmutex.hxx
+++ b/include/comphelper/solarmutex.hxx
@@ -23,6 +23,8 @@
#include <sal/config.h>
#include <assert.h>
+#include <atomic>
+
#include <osl/thread.h>
#include <osl/mutex.hxx>
#include <comphelper/comphelperdllapi.h>
@@ -68,9 +70,10 @@ protected:
osl::Mutex m_aMutex;
sal_uInt32 m_nCount;
- oslThreadIdentifier m_nThreadId;
private:
+ std::atomic<oslThreadIdentifier> m_nThreadId;
+
SolarMutex(const SolarMutex&) = delete;
SolarMutex& operator=(const SolarMutex&) = delete;