Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Correct race condition in ReferenceCounter.DownRef()
Remove race condition during deletion of ReferenceCounter derivatives
were the reference count mutex would be deleted before the mutex locker
could unlock it.
  • Loading branch information
wagnerrp committed Sep 6, 2011
1 parent b47d6de commit 67abc40
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mythtv/libs/libmythbase/referencecounter.cpp
Expand Up @@ -23,7 +23,7 @@ void ReferenceCounter::UpRef(void)

bool ReferenceCounter::DownRef(void)
{
QMutexLocker mlock(&m_refLock);
m_refLock.lock();
m_refCount--;
LOG(VB_GENERAL, LOG_DEBUG, QString("%1(%2)::DownRef() -> %3")
.arg(metaObject()->className())
Expand All @@ -33,10 +33,12 @@ bool ReferenceCounter::DownRef(void)

if (m_refCount == 0)
{
m_refLock.unlock();
delete this;
return true;
}

m_refLock.unlock();
return false;
}

Expand Down

0 comments on commit 67abc40

Please sign in to comment.