From 4526be61403539144062dbbdd3fbbd89aa472b5d Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 29 Jan 2018 12:40:44 +0000 Subject: MAINT-8234 Mesh tread protections and removed unnecessary try in staticRun() --- indra/llcommon/llthread.cpp | 58 ++++++++++++++++----------------------------- 1 file changed, 20 insertions(+), 38 deletions(-) (limited to 'indra/llcommon/llthread.cpp') diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index b96b2ce4bc..e353230791 100644 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -129,50 +129,32 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap sThreadID = threadp->mID; - try + // Run the user supplied function + do { - // Run the user supplied function - do + try { - try - { - threadp->run(); - } - catch (const LLContinueError &e) - { - LL_WARNS("THREAD") << "ContinueException on thread '" << threadp->mName << - "' reentering run(). Error what is: '" << e.what() << "'" << LL_ENDL; - //output possible call stacks to log file. - LLError::LLCallStacks::print(); - - LOG_UNHANDLED_EXCEPTION("LLThread"); - continue; - } - break; - - } while (true); + threadp->run(); + } + catch (const LLContinueError &e) + { + LL_WARNS("THREAD") << "ContinueException on thread '" << threadp->mName << + "' reentering run(). Error what is: '" << e.what() << "'" << LL_ENDL; + //output possible call stacks to log file. + LLError::LLCallStacks::print(); - //LL_INFOS() << "LLThread::staticRun() Exiting: " << threadp->mName << LL_ENDL; + LOG_UNHANDLED_EXCEPTION("LLThread"); + continue; + } + break; - // We're done with the run function, this thread is done executing now. - //NB: we are using this flag to sync across threads...we really need memory barriers here - threadp->mStatus = STOPPED; - } - catch (std::bad_alloc) - { - threadp->mStatus = CRASHED; - LLMemory::logMemoryInfo(TRUE); + } while (true); - //output possible call stacks to log file. - LLError::LLCallStacks::print(); + //LL_INFOS() << "LLThread::staticRun() Exiting: " << threadp->mName << LL_ENDL; - LL_ERRS("THREAD") << "Bad memory allocation in LLThread::staticRun() named '" << threadp->mName << "'!" << LL_ENDL; - } - catch (...) - { - threadp->mStatus = CRASHED; - CRASH_ON_UNHANDLED_EXCEPTION("LLThread"); - } + // We're done with the run function, this thread is done executing now. + //NB: we are using this flag to sync across threads...we really need memory barriers here + threadp->mStatus = STOPPED; delete threadp->mRecorder; threadp->mRecorder = NULL; -- cgit v1.2.3 From 481713000b4b45f2ce6d397aa3326520bbb9da16 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 22 Feb 2018 15:23:14 +0200 Subject: MAINT-8183 Fixed some exit issues and crashes --- indra/llcommon/llthread.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'indra/llcommon/llthread.cpp') diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index 32e8ea9682..1f4aa9b3a6 100644 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -152,13 +152,16 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap //LL_INFOS() << "LLThread::staticRun() Exiting: " << threadp->mName << LL_ENDL; - // We're done with the run function, this thread is done executing now. - //NB: we are using this flag to sync across threads...we really need memory barriers here - threadp->mStatus = STOPPED; delete threadp->mRecorder; threadp->mRecorder = NULL; + // We're done with the run function, this thread is done executing now. + //NB: we are using this flag to sync across threads...we really need memory barriers here + // Todo: add LLMutex per thread instead of flag? + // We are using "while (mStatus != STOPPED) {ms_sleep();}" everywhere. + threadp->mStatus = STOPPED; + return NULL; } -- cgit v1.2.3