diff options
| -rw-r--r-- | indra/llcommon/llqueuedthread.cpp | 27 | ||||
| -rw-r--r-- | indra/llcommon/llqueuedthread.h | 1 | ||||
| -rw-r--r-- | indra/llcommon/llthread.cpp | 14 | ||||
| -rw-r--r-- | indra/llcommon/llwatchdog.cpp | 10 | ||||
| -rw-r--r-- | indra/llcommon/llwatchdog.h | 1 | ||||
| -rw-r--r-- | indra/newview/llappviewer.cpp | 15 |
6 files changed, 60 insertions, 8 deletions
diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp index efeeb1340e..8c740956b3 100644 --- a/indra/llcommon/llqueuedthread.cpp +++ b/indra/llcommon/llqueuedthread.cpp @@ -222,6 +222,33 @@ void LLQueuedThread::waitOnPending() return; } +void LLQueuedThread::waitOnPending(F32 max_time_sec) +{ + LLTimer wait_timer; + wait_timer.reset(); + while (1) + { + update(0); + + if (mIdleThread) + { + break; + } + + if (wait_timer.getElapsedTimeF64() >= max_time_sec) + { + LL_WARNS() << "waitOnPending() timed out after " << max_time_sec + << " seconds in thread: " << mName << LL_ENDL; + break; + } + + if (mThreaded) + { + yield(); + } + } +} + // MAIN thread void LLQueuedThread::printQueueStats() { diff --git a/indra/llcommon/llqueuedthread.h b/indra/llcommon/llqueuedthread.h index de50b8ae95..95f0e58fa8 100644 --- a/indra/llcommon/llqueuedthread.h +++ b/indra/llcommon/llqueuedthread.h @@ -141,6 +141,7 @@ public: size_t updateQueue(F32 max_time_ms); void waitOnPending(); + void waitOnPending(F32 max_time_sec); void printQueueStats(); virtual size_t getPending(); diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index 8c12ee7f12..4f15626108 100644 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -314,11 +314,13 @@ void LLThread::shutdown() // The thread isn't already stopped // First, set the flag that indicates that we're ready to die setQuitting(); + if (!isStopped()) + { + // Give the thread a chance to update status. + yield(); + } //LL_INFOS() << "LLThread::~LLThread() Killing thread " << mName << " Status: " << mStatus << LL_ENDL; - // Now wait a bit for the thread to exit - // It's unclear whether I should even bother doing this - this destructor - // should never get called unless we're already stopped, really... S32 counter = 0; const S32 MAX_WAIT = 600; while (counter < MAX_WAIT) @@ -327,9 +329,9 @@ void LLThread::shutdown() { break; } - // Sleep for a tenth of a second - ms_sleep(100); - yield(); + // Sleep for 10ms, 6 seconds total, then give up and kill the thread + // Warning: This can be called from the main thread + ms_sleep(10); counter++; } } diff --git a/indra/llcommon/llwatchdog.cpp b/indra/llcommon/llwatchdog.cpp index fd0702733c..056a0cc940 100644 --- a/indra/llcommon/llwatchdog.cpp +++ b/indra/llcommon/llwatchdog.cpp @@ -51,6 +51,7 @@ public: { mStopping = true; mSleepMsecs = 1; + setQuitting(); } void run() override @@ -225,11 +226,20 @@ void LLWatchdog::init( mCrashOnFreeze = crash_on_freeze; } +void LLWatchdog::shutdown() +{ + if (mTimer) + { + mTimer->stop(); + } +} + void LLWatchdog::cleanup() { if (mTimer) { mTimer->stop(); + mTimer->shutdown(); delete mTimer; mTimer = nullptr; } diff --git a/indra/llcommon/llwatchdog.h b/indra/llcommon/llwatchdog.h index b286dd179d..3e82fd36b9 100644 --- a/indra/llcommon/llwatchdog.h +++ b/indra/llcommon/llwatchdog.h @@ -107,6 +107,7 @@ public: bool crash_on_freeze); void run(); void cleanup(); + void shutdown(); private: diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index e2bd8798f4..553517472e 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1750,6 +1750,14 @@ bool LLAppViewer::cleanup() LLPluginProcessParent::shutdown(); disconnectViewer(); + + if (LLWatchdog::instanceExists()) + { + // Signal a stop early, so that it will be out + // of sleep loop by the time we get to clean it. + LLWatchdog::getInstance()->shutdown(); + } + LLViewerCamera::deleteSingleton(); LL_INFOS() << "Viewer disconnected" << LL_ENDL; @@ -2079,7 +2087,7 @@ bool LLAppViewer::cleanup() if (sTextureFetch) { sTextureFetch->shutdown(); - sTextureFetch->waitOnPending(); + sTextureFetch->waitOnPending(10.f); delete sTextureFetch; sTextureFetch = NULL; } @@ -2124,7 +2132,10 @@ bool LLAppViewer::cleanup() gSavedSettings.cleanup(); LLUIColorTable::instance().clear(); - LLWatchdog::getInstance()->cleanup(); + if (LLWatchdog::instanceExists()) + { + LLWatchdog::getInstance()->cleanup(); + } LLViewerAssetStatsFF::cleanup(); |
