Browse Source

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)
Palana 11 years ago
parent
commit
7fa7af6c03
1 changed files with 2 additions and 1 deletions
  1. 2 1
      libobs/util/threading.h

+ 2 - 1
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);