diff options
| author | Jonathan "Geenz" Goodman <geenz@geenzo.com> | 2026-08-11 21:39:19 -0400 |
|---|---|---|
| committer | Jonathan "Geenz" Goodman <geenz@geenzo.com> | 2026-08-11 21:39:19 -0400 |
| commit | 8cabc33e960ca93fdc1a32c77cf611269d95d51b (patch) | |
| tree | 931fcecac10bf73214efa07cc3d704ba2bd01272 /indra/llcorehttp/_httpservice.cpp | |
| parent | 9b7ab49575b54523128952af6686d17eb6696725 (diff) | |
| parent | d045f9aa32789a35628aced166145c182751acbf (diff) | |
Merge remote-tracking branch 'origin/develop-linux' into geenz/linux-to-develop
Diffstat (limited to 'indra/llcorehttp/_httpservice.cpp')
| -rw-r--r-- | indra/llcorehttp/_httpservice.cpp | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/indra/llcorehttp/_httpservice.cpp b/indra/llcorehttp/_httpservice.cpp index a8660decc3..e14a533479 100644 --- a/indra/llcorehttp/_httpservice.cpp +++ b/indra/llcorehttp/_httpservice.cpp @@ -70,7 +70,6 @@ volatile HttpService::EState HttpService::sState(NOT_INITIALIZED); HttpService::HttpService() : mRequestQueue(NULL), mExitRequested(0U), - mThread(NULL), mPolicy(NULL), mTransport(NULL), mLastPolicy(0) @@ -89,23 +88,30 @@ HttpService::~HttpService() { if (mRequestQueue->stopQueue()) { - // Give mRequestQueue a chance to finish - ms_sleep(10); + // Now wait a bit for the thread to exit + S32 counter = 0; + const S32 MAX_WAIT = 600; + while (counter < MAX_WAIT) + { + if (STOPPED == sState) + { + break; + } + // Sleep for a tenth of a second + ms_sleep(100); + std::this_thread::yield(); + counter++; + } } } - if (mThread) + if (mThread && RUNNING == sState) { - if (! mThread->timedJoin(250)) - { - // Failed to join, expect problems ahead so do a hard termination. - LL_WARNS(LOG_CORE) << "Destroying HttpService with running thread. Expect problems." << LL_NEWLINE - << "State: " << S32(sState) - << " Last policy: " << U32(mLastPolicy) - << LL_ENDL; + // Failed to shutdown, expect problems ahead so do a hard termination. + LL_WARNS(LOG_CORE) << "Destroying HttpService with running thread. Expect problems." << LL_NEWLINE << "State: " << S32(sState) + << " Last policy: " << U32(mLastPolicy) << LL_ENDL; - mThread->cancel(); - } + mThread->cancel(); } } @@ -121,11 +127,7 @@ HttpService::~HttpService() delete mPolicy; mPolicy = NULL; - if (mThread) - { - mThread->release(); - mThread = NULL; - } + mThread.reset(); } @@ -204,14 +206,15 @@ void HttpService::startThread() if (mThread) { - mThread->release(); + mThread.reset(); } // Push current policy definitions, enable policy & transport components mPolicy->start(); mTransport->start(mLastPolicy + 1); - mThread = new LLCoreInt::HttpThread(boost::bind(&HttpService::threadRun, this, _1)); + mThread = std::make_unique<LLCoreInt::HttpThread>(boost::bind(&HttpService::threadRun, this, _1)); + mThread->detach(); // Detach thread to let it clean its self up sState = RUNNING; } @@ -282,12 +285,9 @@ void HttpService::shutdown() // requested to stop. void HttpService::threadRun(LLCoreInt::HttpThread * thread) { + set_thread_name("HttpService"); LL_PROFILER_SET_THREAD_NAME("HttpService"); - boost::this_thread::disable_interruption di; - - LLThread::registerThreadID(); - ELoopSpeed loop(REQUEST_SLEEP); while (! mExitRequested) { @@ -314,7 +314,7 @@ void HttpService::threadRun(LLCoreInt::HttpThread * thread) { LOG_UNHANDLED_EXCEPTION(""); } - catch (std::bad_alloc&) + catch (const std::bad_alloc&) { LLMemory::logMemoryInfo(true); |
