From 6061296fc7473ed414ca57bdee174caed1bcf52b Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 5 Aug 2024 07:36:47 -0500 Subject: [PATCH] Remove racey condition for starting threads (#4693) Signed-off-by: Quincey Koziol --- test/ttsafe_semaphore.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/ttsafe_semaphore.c b/test/ttsafe_semaphore.c index 3c042734a8d..41076632a4f 100644 --- a/test/ttsafe_semaphore.c +++ b/test/ttsafe_semaphore.c @@ -89,8 +89,7 @@ tts_semaphore_pingpong(void) herr_t result; /* Test set up */ - /* NOTE: ping semaphore starts at 1 */ - result = H5TS_semaphore_init(&test_info.ping_sem, 1); + result = H5TS_semaphore_init(&test_info.ping_sem, 0); CHECK_I(result, "H5TS_semaphore_init"); result = H5TS_semaphore_init(&test_info.pong_sem, 0); CHECK_I(result, "H5TS_semaphore_init"); @@ -102,6 +101,10 @@ tts_semaphore_pingpong(void) result = H5TS_thread_create(&pong_thread, pong, &test_info); CHECK_I(result, "H5TS_thread_create"); + /* Release ping thread */ + result = H5TS_semaphore_signal(&test_info.ping_sem); + CHECK_I(result, "H5TS_semaphore_signal"); + /* Join ping & pong threads */ result = H5TS_thread_join(ping_thread, NULL); CHECK_I(result, "H5TS_thread_join");