mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-13 00:58:29 +02:00
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.
This commit is contained in:
@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user