From edf0874e0656c6f512df50ee52236209531ca329 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 11 Aug 2023 23:36:37 +0300 Subject: SL-18721 Viewer shutdown order changes Same thing as commit cf692c40b0b9f8d0d04cd10a02a84e3f697a2e99 which was removed due to shutdown freezes. Error thread is no longer there so doesn't cause any race sonditions, was not able to repro any issues so will ask QA to test shutdown --- indra/llcommon/threadpool.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/threadpool.cpp') diff --git a/indra/llcommon/threadpool.cpp b/indra/llcommon/threadpool.cpp index d5adf11264..22bbff4478 100644 --- a/indra/llcommon/threadpool.cpp +++ b/indra/llcommon/threadpool.cpp @@ -21,11 +21,12 @@ #include "llevents.h" #include "stringize.h" -LL::ThreadPool::ThreadPool(const std::string& name, size_t threads, size_t capacity): +LL::ThreadPool::ThreadPool(const std::string& name, size_t threads, size_t capacity, bool auto_shutdown): super(name), mQueue(name, capacity), mName("ThreadPool:" + name), - mThreadCount(threads) + mThreadCount(threads), + mAutomaticShutdown(auto_shutdown) {} void LL::ThreadPool::start() @@ -39,6 +40,13 @@ void LL::ThreadPool::start() run(tname); }); } + + // Some threads might need to run longer than LLEventPumps + if (!mAutomaticShutdown) + { + return; + } + // Listen on "LLApp", and when the app is shutting down, close the queue // and join the workers. LLEventPumps::instance().obtain("LLApp").listen( -- cgit v1.2.3 From dc2fc3488d8d1ebb2e90520dd17325f08b7c538b Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 10 Oct 2023 22:32:11 +0300 Subject: Revert "SL-18721 Viewer shutdown order changes" This reverts commit edf0874e0656c6f512df50ee52236209531ca329. Reverted since it causes a significant uptick in shutdown freezes. Can't repro those freezes, will seek an alternate solution. --- indra/llcommon/threadpool.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'indra/llcommon/threadpool.cpp') diff --git a/indra/llcommon/threadpool.cpp b/indra/llcommon/threadpool.cpp index 22bbff4478..d5adf11264 100644 --- a/indra/llcommon/threadpool.cpp +++ b/indra/llcommon/threadpool.cpp @@ -21,12 +21,11 @@ #include "llevents.h" #include "stringize.h" -LL::ThreadPool::ThreadPool(const std::string& name, size_t threads, size_t capacity, bool auto_shutdown): +LL::ThreadPool::ThreadPool(const std::string& name, size_t threads, size_t capacity): super(name), mQueue(name, capacity), mName("ThreadPool:" + name), - mThreadCount(threads), - mAutomaticShutdown(auto_shutdown) + mThreadCount(threads) {} void LL::ThreadPool::start() @@ -40,13 +39,6 @@ void LL::ThreadPool::start() run(tname); }); } - - // Some threads might need to run longer than LLEventPumps - if (!mAutomaticShutdown) - { - return; - } - // Listen on "LLApp", and when the app is shutting down, close the queue // and join the workers. LLEventPumps::instance().obtain("LLApp").listen( -- cgit v1.2.3 From 4a34a1196627c7e9998edde725d5e839f3ef61b9 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Sat, 20 Jan 2024 02:26:51 +0200 Subject: SL-18721 Shutdown fixes 1. After window closes viewer still takes some time to shut down, so added splash screen to not confuse users (and to see if something gets stuck) 2. Having two identical mWindowHandle caused confusion for me, so I split them. It looks like there might have been issues with thread being stuck because thread's handle wasn't cleaned up. 3. Made region clean mCacheMap immediately instead of spending time making copies on shutdown --- indra/llcommon/threadpool.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'indra/llcommon/threadpool.cpp') diff --git a/indra/llcommon/threadpool.cpp b/indra/llcommon/threadpool.cpp index 3a9a5a2062..a063a01b82 100644 --- a/indra/llcommon/threadpool.cpp +++ b/indra/llcommon/threadpool.cpp @@ -60,12 +60,15 @@ struct sleepy_robin: public boost::fibers::algo::round_robin /***************************************************************************** * ThreadPoolBase *****************************************************************************/ -LL::ThreadPoolBase::ThreadPoolBase(const std::string& name, size_t threads, - WorkQueueBase* queue): +LL::ThreadPoolBase::ThreadPoolBase(const std::string& name, + size_t threads, + WorkQueueBase* queue, + bool auto_shutdown): super(name), mName("ThreadPool:" + name), mThreadCount(getConfiguredWidth(name, threads)), - mQueue(queue) + mQueue(queue), + mAutomaticShutdown(auto_shutdown) {} void LL::ThreadPoolBase::start() @@ -79,6 +82,14 @@ void LL::ThreadPoolBase::start() run(tname); }); } + + if (!mAutomaticShutdown) + { + // Some threads, like main window's might need to run a bit longer + // to wait for a proper shutdown message + return; + } + // Listen on "LLApp", and when the app is shutting down, close the queue // and join the workers. LLEventPumps::instance().obtain("LLApp").listen( -- cgit v1.2.3 From 18ec799992e0e2571ed3d3a61454be682a81aa16 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 27 Feb 2024 23:02:00 +0200 Subject: SL-18721 Shutdown fixes #5 --- indra/llcommon/threadpool.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/threadpool.cpp') diff --git a/indra/llcommon/threadpool.cpp b/indra/llcommon/threadpool.cpp index a063a01b82..c48989358e 100644 --- a/indra/llcommon/threadpool.cpp +++ b/indra/llcommon/threadpool.cpp @@ -120,8 +120,11 @@ void LL::ThreadPoolBase::close() mQueue->close(); for (auto& pair: mThreads) { - LL_DEBUGS("ThreadPool") << mName << " waiting on thread " << pair.first << LL_ENDL; - pair.second.join(); + if (pair.second.joinable()) + { + LL_DEBUGS("ThreadPool") << mName << " waiting on thread " << pair.first << LL_ENDL; + pair.second.join(); + } } LL_DEBUGS("ThreadPool") << mName << " shutdown complete" << LL_ENDL; } -- cgit v1.2.3