Revert "Fix crash at exit due to a unreleased mutex."
This reverts commit 80e5470006
.
std::unique_lock is incapable of recursively locking a mutex, which is needed for multi-monitor setups.
As a result it will crash/show undefined behaviour when switching renderers. Switch to instead calling
endblit() after pc_close to avoid crashes; at this point the CPU thread is now terminated so the mutex
no longer remains held by it.
This commit is contained in:
@@ -289,6 +289,7 @@ int main(int argc, char* argv[]) {
|
|||||||
cpu_thread_run = 0;
|
cpu_thread_run = 0;
|
||||||
main_thread->join();
|
main_thread->join();
|
||||||
pc_close(nullptr);
|
pc_close(nullptr);
|
||||||
|
endblit();
|
||||||
|
|
||||||
socket.close();
|
socket.close();
|
||||||
return ret;
|
return ret;
|
||||||
|
@@ -54,7 +54,6 @@ QElapsedTimer elapsed_timer;
|
|||||||
|
|
||||||
static std::atomic_int blitmx_contention = 0;
|
static std::atomic_int blitmx_contention = 0;
|
||||||
static std::recursive_mutex blitmx;
|
static std::recursive_mutex blitmx;
|
||||||
static thread_local std::unique_lock blit_lock { blitmx, std::defer_lock };
|
|
||||||
|
|
||||||
class CharPointer {
|
class CharPointer {
|
||||||
public:
|
public:
|
||||||
@@ -469,17 +468,17 @@ void dynld_close(void *handle)
|
|||||||
void startblit()
|
void startblit()
|
||||||
{
|
{
|
||||||
blitmx_contention++;
|
blitmx_contention++;
|
||||||
if (blit_lock.try_lock()) {
|
if (blitmx.try_lock()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
blit_lock.lock();
|
blitmx.lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void endblit()
|
void endblit()
|
||||||
{
|
{
|
||||||
blitmx_contention--;
|
blitmx_contention--;
|
||||||
blit_lock.unlock();
|
blitmx.unlock();
|
||||||
if (blitmx_contention > 0) {
|
if (blitmx_contention > 0) {
|
||||||
// a deadlock has been observed on linux when toggling via video_toggle_option
|
// a deadlock has been observed on linux when toggling via video_toggle_option
|
||||||
// because the mutex is typically unfair on linux
|
// because the mutex is typically unfair on linux
|
||||||
|
Reference in New Issue
Block a user