From 7fa7af6c030d246be6b4d6f76476f7f019da493a Mon Sep 17 00:00:00 2001 From: Palana Date: Mon, 6 Jan 2014 02:04:32 +0100 Subject: [PATCH] check for signalled event before pthread_cond_wait-ing fixes a deadlock in obs_free_video/obs_video_thread where video_output_stop would signal the update event before obs_video_thread enters video_output_wait (the thread calling obs_free_video would block on pthread_join and obs_video_thread would block on pthread_cond_wait) --- libobs/util/threading.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libobs/util/threading.h b/libobs/util/threading.h index c37045c56..75e115562 100644 --- a/libobs/util/threading.h +++ b/libobs/util/threading.h @@ -83,7 +83,8 @@ static inline int event_wait(event_t *event) { int code = 0; pthread_mutex_lock(&event->mutex); - if ((code = pthread_cond_wait(&event->cond, &event->mutex)) == 0) { + if (event->signalled || + (code = pthread_cond_wait(&event->cond, &event->mutex)) == 0) { if (!event->manual) event->signalled = false; pthread_mutex_unlock(&event->mutex); -- GitLab