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.
This commit is contained in:
Connor McLaughlin 2020-12-06 00:41:06 +10:00
parent 1e322191ea
commit fd6462263f
1 changed files with 5 additions and 1 deletions

View File

@ -5,6 +5,7 @@
#include "windows_headers.h"
#include <malloc.h>
#elif defined(__linux__) || defined(__APPLE__) || defined(__HAIKU__)
#include <errno.h>
#include <time.h>
#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();