]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Use correct function to wait for condvar
authorHugo Landau <hlandau@openssl.org>
Mon, 27 Mar 2023 15:03:32 +0000 (16:03 +0100)
committerHugo Landau <hlandau@openssl.org>
Thu, 30 Mar 2023 10:14:17 +0000 (11:14 +0100)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20348)

crypto/thread/arch.c
crypto/thread/internal.c

index 8d6f4777066fa78547a4f0ef64b242eb48c464b6..f6a83540b37aaab2d8431bb789b5cdea7f7a1b54 100644 (file)
@@ -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;
index 4d966f3e53be337b84094f6fcf63b21c95afbd67..688848738bd19971c9246d3ed81b2468f56de909 100644 (file)
@@ -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;
 }