From 72956d59c8a6c81b994f80c3cd14b58d7ea268c8 Mon Sep 17 00:00:00 2001 From: joewestcott Date: Wed, 6 May 2015 05:36:37 +0100 Subject: [PATCH 1/2] Reverts pull request #2362, fixes issue 8542. --- Source/Core/Core/HW/CPU.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Core/HW/CPU.cpp b/Source/Core/Core/HW/CPU.cpp index ff3c39d572..f583cc3dfe 100644 --- a/Source/Core/Core/HW/CPU.cpp +++ b/Source/Core/Core/HW/CPU.cpp @@ -150,9 +150,9 @@ bool CCPU::PauseAndLock(bool doLock, bool unpauseOnUnlock) if (doLock) { // we can't use EnableStepping, that would causes deadlocks with both audio and video + PowerPC::Pause(); if (!Core::IsCPUThread()) m_csCpuOccupied.lock(); - PowerPC::Pause(); } else { From 3fe839d225c200245005f14b0a854bac327c871e Mon Sep 17 00:00:00 2001 From: Jonathan Dieter Date: Wed, 6 May 2015 21:53:53 +0300 Subject: [PATCH 2/2] Avoid deadlock when adding Wiimotes (attempt #2) Signed-off-by: Jonathan Dieter --- Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp index f64ab52769..319a6bddb7 100644 --- a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp +++ b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp @@ -829,7 +829,10 @@ void ControlChannel(int _WiimoteNumber, u16 _channelID, const void* _pData, u32 // Read the Wiimote once void Update(int _WiimoteNumber) { - std::lock_guard lk(g_refresh_lock); + // Try to get a lock and return without doing anything if we fail + // This avoids deadlocks when adding a Wiimote during continuous scan + if(!g_refresh_lock.try_lock()) + return; if (g_wiimotes[_WiimoteNumber]) g_wiimotes[_WiimoteNumber]->Update(); @@ -839,6 +842,7 @@ void Update(int _WiimoteNumber) { Host_ConnectWiimote(_WiimoteNumber, false); } + g_refresh_lock.unlock(); } void StateChange(EMUSTATE_CHANGE newState)