summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
diff options
context:
space:
mode:
authorFiloppi <filippotarpini@hotmail.it>2021-05-15 11:25:20 +0300
committerFiloppi <filippotarpini@hotmail.it>2021-06-07 11:07:05 +0300
commitc285ae57fb0027a3e6da12b7097e15e0485ee526 (patch)
tree4ea20b10e2477637ecb87896a574a8bce16442ef /Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
parentebe3fbe04c329f9bc100ded4dcf22720f375e2f4 (diff)
ControllerInterface: fix rare deadlock
A "devices changed" callback could have ended up waiting on another thread that was also populating devices and waiting on the previous thread to release the callbacks mutex.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
index 0cae47c741..afdf768435 100644
--- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
@@ -322,7 +322,9 @@ void ControllerInterface::UnregisterDevicesChangedCallback(const HotplugCallback
// Invoke all callbacks that were registered
void ControllerInterface::InvokeDevicesChangedCallbacks() const
{
- std::lock_guard<std::mutex> lk(m_callbacks_mutex);
- for (const auto& callback : m_devices_changed_callbacks)
+ m_callbacks_mutex.lock();
+ const auto devices_changed_callbacks = m_devices_changed_callbacks;
+ m_callbacks_mutex.unlock();
+ for (const auto& callback : devices_changed_callbacks)
callback();
}