Kaydet (Commit) 9b3eeff0 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

SolarMutex::m_nThreadId is read without SolarMutex::m_aMutex locked

...so better make it std::atomic<> (and it also can be private).  And in
SolarMutex::doRelease, make sure that m_nCount is only read with m_aMutex
locked.

Change-Id: Iee0c1465e60e07ccd8955010a3dbc15a99dbe807
Reviewed-on: https://gerrit.libreoffice.org/71260
Tested-by: Jenkins
Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst f214d664
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment