From 0294bfeb58313441029cd5e730e6e33e83ca99ed Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 8 Dec 2023 03:52:23 +0000 Subject: [PATCH] library: fix freezing on game exit --- src/library/so/main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/library/so/main.c b/src/library/so/main.c index 5d5c5c4..8e738dd 100644 --- a/src/library/so/main.c +++ b/src/library/so/main.c @@ -555,7 +555,12 @@ void glFlush() { SEND_MSG({.instruction = Message_glFlush, .data = &data}) real_glFlush(); pthread_mutex_lock(&data.mutex); - while (!data.done) pthread_cond_wait(&data.cond, &data.mutex); + while (!data.done) { + pthread_mutex_lock(&egl_lock); + uint8_t running = worker_thread_running; + pthread_mutex_unlock(&egl_lock); + if (running) pthread_cond_wait(&data.cond, &data.mutex); + } pthread_mutex_unlock(&data.mutex); pthread_mutex_destroy(&data.mutex); pthread_cond_destroy(&data.cond);