From 712360631ff95b412883fbcd56dd44752d427565 Mon Sep 17 00:00:00 2001 From: Hugo Landau Date: Mon, 27 Mar 2023 16:03:32 +0100 Subject: [PATCH] Use correct function to wait for condvar Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/20348) --- crypto/thread/arch.c | 13 ++++++------- crypto/thread/internal.c | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/crypto/thread/arch.c b/crypto/thread/arch.c index 8d6f477706..f6a83540b3 100644 --- a/crypto/thread/arch.c +++ b/crypto/thread/arch.c @@ -78,13 +78,12 @@ pass: CRYPTO_THREAD_SET_STATE(thread, CRYPTO_THREAD_JOINED); /* - * Broadcast join completion. It is important to broadcast even if - * we haven't performed an actual join. Multiple threads could be - * awaiting the CRYPTO_THREAD_JOIN_AWAIT -> CRYPTO_THREAD_JOINED - * transition, but broadcast on actual join would wake only one. - * Broadcasing here will always wake one. + * Signal join completion. It is important to signal even if we haven't + * performed an actual join. Multiple threads could be awaiting the + * CRYPTO_THREAD_JOIN_AWAIT -> CRYPTO_THREAD_JOINED transition, but signal + * on actual join would wake only one. Signalling here will always wake one. */ - ossl_crypto_condvar_broadcast(thread->condvar); + ossl_crypto_condvar_signal(thread->condvar); ossl_crypto_mutex_unlock(thread->statelock); if (retval != NULL) @@ -98,7 +97,7 @@ fail: /* Have another thread that's awaiting join retry to avoid that * thread deadlock. */ CRYPTO_THREAD_UNSET_STATE(thread, CRYPTO_THREAD_JOIN_AWAIT); - ossl_crypto_condvar_broadcast(thread->condvar); + ossl_crypto_condvar_signal(thread->condvar); ossl_crypto_mutex_unlock(thread->statelock); return 0; diff --git a/crypto/thread/internal.c b/crypto/thread/internal.c index 4d966f3e53..688848738b 100644 --- a/crypto/thread/internal.c +++ b/crypto/thread/internal.c @@ -87,7 +87,7 @@ int ossl_crypto_thread_join(void *vhandle, CRYPTO_THREAD_RETVAL *retval) ossl_crypto_mutex_lock(tdata->lock); tdata->active_threads--; - ossl_crypto_condvar_broadcast(tdata->cond_finished); + ossl_crypto_condvar_signal(tdata->cond_finished); ossl_crypto_mutex_unlock(tdata->lock); return 1; }