Added _lockCount>0 check to lock,unlock and trylock to make sure that it

is set properly on first time entry.
This commit is contained in:
Robert Osfield
2004-11-19 20:05:14 +00:00
parent 65d4e0428e
commit 3bf21bf3b6

View File

@@ -28,7 +28,7 @@ ReentrantMutex::~ReentrantMutex()
int ReentrantMutex::lock()
{
if (_threadHoldingMutex==OpenThreads::Thread::CurrentThread())
if (_threadHoldingMutex==OpenThreads::Thread::CurrentThread() && _lockCount>0)
{
++_lockCount;
return 0;
@@ -47,7 +47,7 @@ int ReentrantMutex::lock()
int ReentrantMutex::unlock()
{
if (_threadHoldingMutex==OpenThreads::Thread::CurrentThread())
if (_threadHoldingMutex==OpenThreads::Thread::CurrentThread() && _lockCount>0)
{
--_lockCount;
if (_lockCount<=0) return Mutex::unlock();
@@ -57,7 +57,7 @@ int ReentrantMutex::unlock()
int ReentrantMutex::trylock()
{
if (_threadHoldingMutex==OpenThreads::Thread::CurrentThread())
if (_threadHoldingMutex==OpenThreads::Thread::CurrentThread() && _lockCount>0)
{
++_lockCount;
return 0;