]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
dso: update to structure based atomics
authorPauli <pauli@openssl.org>
Wed, 21 Jun 2023 23:29:24 +0000 (09:29 +1000)
committerPauli <pauli@openssl.org>
Sat, 1 Jul 2023 11:18:25 +0000 (21:18 +1000)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21260)

crypto/dso/dso_lib.c
crypto/dso/dso_local.h

index a73d91e839718ea9c5e55456381390314f9b6032..7680c40547a010c1545d62faf3cb4b40094bf0de 100644 (file)
@@ -25,10 +25,7 @@ static DSO *DSO_new_method(DSO_METHOD *meth)
         return NULL;
     }
     ret->meth = DSO_METHOD_openssl();
-    ret->references = 1;
-    ret->lock = CRYPTO_THREAD_lock_new();
-    if (ret->lock == NULL) {
-        ERR_raise(ERR_LIB_DSO, ERR_R_CRYPTO_LIB);
+    if (!CRYPTO_NEW_REF(&ret->references, 1)) {
         sk_void_free(ret->meth_data);
         OPENSSL_free(ret);
         return NULL;
@@ -54,7 +51,7 @@ int DSO_free(DSO *dso)
     if (dso == NULL)
         return 1;
 
-    if (CRYPTO_DOWN_REF(&dso->references, &i, dso->lock) <= 0)
+    if (CRYPTO_DOWN_REF(&dso->references, &i) <= 0)
         return 0;
 
     REF_PRINT_COUNT("DSO", dso);
@@ -77,7 +74,7 @@ int DSO_free(DSO *dso)
     sk_void_free(dso->meth_data);
     OPENSSL_free(dso->filename);
     OPENSSL_free(dso->loaded_filename);
-    CRYPTO_THREAD_lock_free(dso->lock);
+    CRYPTO_FREE_REF(&dso->references);
     OPENSSL_free(dso);
     return 1;
 }
@@ -96,7 +93,7 @@ int DSO_up_ref(DSO *dso)
         return 0;
     }
 
-    if (CRYPTO_UP_REF(&dso->references, &i, dso->lock) <= 0)
+    if (CRYPTO_UP_REF(&dso->references, &i) <= 0)
         return 0;
 
     REF_PRINT_COUNT("DSO", dso);
index 8aa29c1826fec97e2c29cb7869e674ffac2f4825..3100ba08446156bbf4b09ee33504773c37b1d107 100644 (file)
@@ -61,7 +61,6 @@ struct dso_st {
      * loaded.
      */
     char *loaded_filename;
-    CRYPTO_RWLOCK *lock;
 };
 
 struct dso_meth_st {