From 5fff4c35fcafb9a7e70cfe99ce78e42309df8dfa Mon Sep 17 00:00:00 2001
From: James R <justsomejames2@gmail.com>
Date: Mon, 27 Apr 2020 18:01:27 -0700
Subject: [PATCH] Create cond if it doesn't exist when signaling

---
 src/i_threads.h     |  4 ++--
 src/sdl/i_threads.c | 26 ++++++++++++++++++++++----
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/src/i_threads.h b/src/i_threads.h
index 878e8c388e..45a3dcc3ef 100644
--- a/src/i_threads.h
+++ b/src/i_threads.h
@@ -32,8 +32,8 @@ void      I_unlock_mutex    (I_mutex);
 
 void      I_hold_cond       (I_cond *, I_mutex);
 
-void      I_wake_one_cond   (I_cond);
-void      I_wake_all_cond   (I_cond);
+void      I_wake_one_cond   (I_cond *);
+void      I_wake_all_cond   (I_cond *);
 
 #endif/*I_THREADS_H*/
 #endif/*HAVE_THREADS*/
diff --git a/src/sdl/i_threads.c b/src/sdl/i_threads.c
index 99e574561b..078f4e0f46 100644
--- a/src/sdl/i_threads.c
+++ b/src/sdl/i_threads.c
@@ -323,16 +323,34 @@ I_hold_cond (
 
 void
 I_wake_one_cond (
-		I_cond id
+		I_cond * anchor
 ){
-	if (SDL_CondSignal(id) == -1)
+	SDL_cond * cond;
+
+	cond = Identity(
+			&i_cond_pool,
+			i_cond_pool_mutex,
+			anchor,
+			(Create_fn)SDL_CreateCond
+	);
+
+	if (SDL_CondSignal(cond) == -1)
 		abort();
 }
 
 void
 I_wake_all_cond (
-		I_cond id
+		I_cond * anchor
 ){
-	if (SDL_CondBroadcast(id) == -1)
+	SDL_cond * cond;
+
+	cond = Identity(
+			&i_cond_pool,
+			i_cond_pool_mutex,
+			anchor,
+			(Create_fn)SDL_CreateCond
+	);
+
+	if (SDL_CondBroadcast(cond) == -1)
 		abort();
 }
-- 
GitLab