diff options
author | Hugo Landau <hlandau@openssl.org> | 2023-03-27 16:03:32 +0100 |
---|---|---|
committer | Hugo Landau <hlandau@openssl.org> | 2023-03-30 11:14:17 +0100 |
commit | 712360631ff95b412883fbcd56dd44752d427565 (patch) | |
tree | be430d0715e74c5471eb16f7dcff695bfaba55eb | |
parent | 652fbb62a3de29f8c9103c66ac2bc27ac44b032a (diff) |
Use correct function to wait for condvar
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20348)
-rw-r--r-- | crypto/thread/arch.c | 13 | ||||
-rw-r--r-- | 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; } |