Fix LL_REF_COUNT_DEBUG debug code.

This code was broken with respect to LLAPRPool.
Fix that, and also fixed it for the new AIThreadID API.
This commit is contained in:
Aleric Inglewood
2012-08-09 07:00:51 +02:00
parent b9673df961
commit cd197a3807
6 changed files with 17 additions and 58 deletions

View File

@@ -41,6 +41,7 @@
#include "lldir.h"
#include "llendianswizzle.h"
#include "llassetstorage.h"
#include "llrefcount.h"
#include "vorbis/codec.h"
#include "vorbis/vorbisfile.h"

View File

@@ -48,6 +48,7 @@
#include "apr_portable.h"
#include "apr_pools.h"
#include "llerror.h"
#include "aithreadid.h"
extern void ll_init_apr();

View File

@@ -523,7 +523,6 @@ void LLPrivateMemoryPoolTester::operator delete[](void* addr)
//EVENTUALLY REMOVE THESE:
#include "llpointer.h"
#include "llrefcount.h"
#include "llsingleton.h"
#include "llsafehandle.h"

View File

@@ -38,14 +38,6 @@ LLRefCount::LLRefCount(const LLRefCount& other)
: mRef(0)
{
#if LL_REF_COUNT_DEBUG
if(gAPRPoolp)
{
mMutexp = new LLMutex(gAPRPoolp) ;
}
else
{
mMutexp = NULL ;
}
mCrashAtUnlock = FALSE ;
#endif
}
@@ -60,14 +52,6 @@ LLRefCount::LLRefCount() :
mRef(0)
{
#if LL_REF_COUNT_DEBUG
if(gAPRPoolp)
{
mMutexp = new LLMutex(gAPRPoolp) ;
}
else
{
mMutexp = NULL ;
}
mCrashAtUnlock = FALSE ;
#endif
}
@@ -78,29 +62,20 @@ LLRefCount::~LLRefCount()
{
llerrs << "deleting non-zero reference" << llendl;
}
#if LL_REF_COUNT_DEBUG
if(gAPRPoolp)
{
delete mMutexp ;
}
#endif
}
#if LL_REF_COUNT_DEBUG
void LLRefCount::ref() const
{
if(mMutexp)
{
if(mMutexp->isLocked())
if(mMutex.isLocked())
{
mCrashAtUnlock = TRUE ;
llerrs << "the mutex is locked by the thread: " << mLockedThreadID
<< " Current thread: " << LLThread::currentID() << llendl ;
<< " Current thread: " << AIThreadID() << llendl ;
}
mMutexp->lock() ;
mLockedThreadID = LLThread::currentID() ;
mMutex.lock() ;
mLockedThreadID.reset();
mRef++;
@@ -108,27 +83,20 @@ void LLRefCount::ref() const
{
while(1); //crash here.
}
mMutexp->unlock() ;
}
else
{
mRef++;
}
mMutex.unlock() ;
}
S32 LLRefCount::unref() const
{
if(mMutexp)
{
if(mMutexp->isLocked())
if(mMutex.isLocked())
{
mCrashAtUnlock = TRUE ;
llerrs << "the mutex is locked by the thread: " << mLockedThreadID
<< " Current thread: " << LLThread::currentID() << llendl ;
<< " Current thread: " << AIThreadID() << llendl ;
}
mMutexp->lock() ;
mLockedThreadID = LLThread::currentID() ;
mMutex.lock() ;
mLockedThreadID.reset();
llassert(mRef >= 1);
if (0 == --mRef)
@@ -137,7 +105,7 @@ S32 LLRefCount::unref() const
{
while(1); //crash here.
}
mMutexp->unlock() ;
mMutex.unlock() ;
delete this;
return 0;
@@ -147,18 +115,7 @@ S32 LLRefCount::unref() const
{
while(1); //crash here.
}
mMutexp->unlock() ;
mMutex.unlock() ;
return mRef;
}
else
{
llassert(mRef >= 1);
if (0 == --mRef)
{
delete this;
return 0;
}
return mRef;
}
}
#endif

View File

@@ -30,7 +30,7 @@
#define LL_REF_COUNT_DEBUG 0
#if LL_REF_COUNT_DEBUG
class LLMutex ;
#include "llthread.h" // LLMutexRootPool
#endif
//----------------------------------------------------------------------------
@@ -80,8 +80,8 @@ private:
mutable S32 mRef;
#if LL_REF_COUNT_DEBUG
LLMutex* mMutexp ;
mutable U32 mLockedThreadID ;
mutable LLMutexRootPool mMutex ;
mutable AIThreadID mLockedThreadID ;
mutable BOOL mCrashAtUnlock ;
#endif
};

View File

@@ -42,6 +42,7 @@
#include "v4color.h"
#include "v4coloru.h"
#include "llinstancetracker.h"
#include "llrefcount.h"
#include "llcontrolgroupreader.h"