diff options
| author | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2026-07-19 10:47:11 +0300 |
|---|---|---|
| committer | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2026-07-20 20:32:48 +0300 |
| commit | ce21ab1950b685b84ba0651d51cc4c200763860c (patch) | |
| tree | 86b4226dc4163ec01a55a00ca8d56be784a00cc6 /indra/llcommon | |
| parent | 331c3c758a114d23950ab23bb94ee19e85e662dd (diff) | |
#6014 Reduce shutdown delays on thread cleanup
Diffstat (limited to 'indra/llcommon')
| -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 |
5 files changed, 47 insertions, 6 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: |
