From 0c9d4db072ab220b02b801595db5fc9ce3dfe6e0 Mon Sep 17 00:00:00 2001 From: Beq Date: Tue, 3 Jan 2023 18:50:24 +0000 Subject: [PATCH] [FIRE-32453][BUG-232971] Orderly shutdown of event queues Terminate related queues before the windows thread to avoid loops. Also increase timeout on queue full wait as we don't expect to see this so often now. --- indra/llcommon/llthreadsafequeue.h | 6 ++++-- indra/llwindow/llwindowwin32.cpp | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/indra/llcommon/llthreadsafequeue.h b/indra/llcommon/llthreadsafequeue.h index f7cd940a06..8329041a5c 100644 --- a/indra/llcommon/llthreadsafequeue.h +++ b/indra/llcommon/llthreadsafequeue.h @@ -343,8 +343,10 @@ bool LLThreadSafeQueue::pushIfOpen(T&& element) // Storage Full. Wait for signal. // [FIRE-32453][BUG-232971] Improve shutdown behaviour. Time bound the sleep - // When the queue is full and the consuming thread has exited we will never wake up. - const auto timeout = std::chrono::milliseconds(50); + // mCapacityCond.wait(lock1); + // When the queue is full and the consuming thread has exited we would never wake up. + // For safety, we now wait max half a second then recheck close. + const auto timeout = std::chrono::milliseconds(500); mCapacityCond.wait_for(lock1, timeout); // } diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 1b9b65b346..f146b71b6e 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -925,6 +925,10 @@ void LLWindowWin32::close() // operations we're asking. That's the last time WE should touch it. mhDC = NULL; mWindowHandle = NULL; + // [FIRE-32453][BUG-232971] close the related queues first to prevent spinning. + mFunctionQueue.close(); + mMouseQueue.close(); + // mWindowThread->close(); }