diff --git a/indra/llmessage/aicurl.cpp b/indra/llmessage/aicurl.cpp index bfd2a2243..11668f5fc 100644 --- a/indra/llmessage/aicurl.cpp +++ b/indra/llmessage/aicurl.cpp @@ -418,6 +418,7 @@ void cleanupCurl(void) if (CurlMultiHandle::getTotalMultiHandles() != 0) llwarns << "Not all CurlMultiHandle objects were destroyed!" << llendl; AIStateMachine::flush(); + clearCommandQueue(); Stats::print(); ssl_cleanup(); diff --git a/indra/llmessage/aicurlprivate.h b/indra/llmessage/aicurlprivate.h index abb663d4a..ee28ae849 100644 --- a/indra/llmessage/aicurlprivate.h +++ b/indra/llmessage/aicurlprivate.h @@ -119,6 +119,7 @@ inline CURLMcode check_multi_code(CURLMcode code) { AICurlInterface::Stats::mult bool curlThreadIsRunning(void); void wakeUpCurlThread(void); void stopCurlThread(void); +void clearCommandQueue(void); #define DECLARE_SETOPT(param_type) \ CURLcode setopt(CURLoption option, param_type parameter) diff --git a/indra/llmessage/aicurlthread.cpp b/indra/llmessage/aicurlthread.cpp index 1fbe57d3e..ae686c087 100644 --- a/indra/llmessage/aicurlthread.cpp +++ b/indra/llmessage/aicurlthread.cpp @@ -1065,6 +1065,10 @@ void AICurlThread::wakeup_thread(void) DoutEntering(dc::curl, "AICurlThread::wakeup_thread"); llassert(is_main_thread()); + // If we are already exiting the viewer then return immediately. + if (!mRunning) + return; + // Try if curl thread is still awake and if so, pass the new commands directly. if (mWakeUpMutex.tryLock()) { @@ -2148,10 +2152,14 @@ void stopCurlThread(void) ms_sleep(10); } Dout(dc::curl, "Curl thread" << (curlThreadIsRunning() ? " not" : "") << " stopped after " << ((100 - count) * 10) << "ms."); - // Clear the command queue, for a cleaner cleanup. + } +} + +void clearCommandQueue(void) +{ + // Clear the command queue now in order to avoid the global deinitialization order fiasco. command_queue_wat command_queue_w(command_queue); command_queue_w->clear(); - } } //-----------------------------------------------------------------------------