From 1f4b9adbf569fe851c314bc4eae2dc0d9f3b5a4f Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Sun, 2 Aug 2020 23:20:33 +0100 Subject: [PATCH] ISO/USB: fix potential race condition --- Source/Core/Core/IOS/USB/Host.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/Core/Core/IOS/USB/Host.cpp b/Source/Core/Core/IOS/USB/Host.cpp index f6ab6ed661..460f5a859f 100644 --- a/Source/Core/Core/IOS/USB/Host.cpp +++ b/Source/Core/Core/IOS/USB/Host.cpp @@ -179,9 +179,8 @@ void USBHost::StartThreads() if (Core::WantsDeterminism()) return; - if (!m_scan_thread_running.IsSet()) + if (m_scan_thread_running.TestAndSet()) { - m_scan_thread_running.Set(); m_scan_thread = std::thread([this] { Common::SetCurrentThreadName("USB Scan Thread"); while (m_scan_thread_running.IsSet())