From fd6462263f343786d59f13e3978e9a0eb1b326f9 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 6 Dec 2020 00:41:06 +1000 Subject: [PATCH] Common/Event: Fix TryWait not returning on timeout on Linux Fixes a potential deadlock in the Qt frontend if initialization on the emu thread takes too long. --- src/common/event.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/common/event.cpp b/src/common/event.cpp index 798b9c0b4..07a5db36b 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -5,6 +5,7 @@ #include "windows_headers.h" #include #elif defined(__linux__) || defined(__APPLE__) || defined(__HAIKU__) +#include #include #endif @@ -169,7 +170,10 @@ bool Event::TryWait(u32 timeout_in_ms) pthread_mutex_lock(&m_mutex); while (!m_signaled.load()) - pthread_cond_timedwait(&m_cv, &m_mutex, &ts); + { + if (pthread_cond_timedwait(&m_cv, &m_mutex, &ts) != 0) + break; + } const bool result = m_signaled.load();