SH-4653 FIX Interesting: Viewer crashes while reading chat history

fix for crash on exit resulting from 8c0e024d0c33
master
Richard Linden 2013-12-10 15:48:57 -08:00
parent 0b40ee53e3
commit 1522c1b3bd
3 changed files with 20 additions and 10 deletions

View File

@ -146,6 +146,9 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap
// We're done with the run function, this thread is done executing now.
threadp->mStatus = STOPPED;
delete threadp->mRecorder;
threadp->mRecorder = NULL;
return NULL;
}
@ -153,7 +156,8 @@ LLThread::LLThread(const std::string& name, apr_pool_t *poolp) :
mPaused(FALSE),
mName(name),
mAPRThreadp(NULL),
mStatus(STOPPED)
mStatus(STOPPED),
mRecorder(NULL)
{
mID = ++sIDIter;
@ -242,7 +246,13 @@ void LLThread::shutdown()
mAPRPoolp = 0;
}
delete mRecorder;
if (mRecorder)
{
// missed chance to properly shut down recorder (needs to be done in thread context)
// probably due to abnormal thread termination
// so just leak it and remove it from parent
LLTrace::get_master_thread_recorder()->removeChildRecorder(mRecorder);
}
}

View File

@ -40,7 +40,7 @@ static ThreadRecorder* sMasterThreadRecorder = NULL;
///////////////////////////////////////////////////////////////////////
ThreadRecorder::ThreadRecorder()
: mMasterRecorder(NULL)
: mParentRecorder(NULL)
{
init();
}
@ -86,11 +86,11 @@ void ThreadRecorder::init()
}
ThreadRecorder::ThreadRecorder( ThreadRecorder& master )
: mMasterRecorder(&master)
ThreadRecorder::ThreadRecorder( ThreadRecorder& parent )
: mParentRecorder(&parent)
{
init();
mMasterRecorder->addChildRecorder(this);
mParentRecorder->addChildRecorder(this);
}
@ -115,9 +115,9 @@ ThreadRecorder::~ThreadRecorder()
set_thread_recorder(NULL);
delete[] mTimeBlockTreeNodes;
if (mMasterRecorder)
if (mParentRecorder)
{
mMasterRecorder->removeChildRecorder(this);
mParentRecorder->removeChildRecorder(this);
}
}

View File

@ -43,7 +43,7 @@ namespace LLTrace
typedef std::vector<ActiveRecording*> active_recording_list_t;
public:
ThreadRecorder();
explicit ThreadRecorder(ThreadRecorder& master);
explicit ThreadRecorder(ThreadRecorder& parent);
~ThreadRecorder();
@ -88,7 +88,7 @@ namespace LLTrace
LLMutex mChildListMutex; // protects access to child list
LLMutex mSharedRecordingMutex;
AccumulatorBufferGroup mSharedRecordingBuffers;
ThreadRecorder* mMasterRecorder;
ThreadRecorder* mParentRecorder;
};