]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
test: update to structure based atomics
authorPauli <pauli@openssl.org>
Wed, 21 Jun 2023 23:37:23 +0000 (09:37 +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)

test/tls-provider.c

index 6c7cd2a2af1231e206f950ad235dd83e8023863b..39dde831f48560bba28f0499277dad249feaed57 100644 (file)
@@ -78,7 +78,6 @@ typedef struct xorkey_st {
     int haspubkey;
     char *tls_name;
     CRYPTO_REF_COUNT references;
-    CRYPTO_RWLOCK *lock;
 } XORKEY;
 
 /* Key Management for the dummy XOR KEX, KEM and signature algorithms */
@@ -688,10 +687,7 @@ static void *xor_newkey(void *provctx)
     if (ret == NULL)
         return NULL;
 
-    ret->references = 1;
-    ret->lock = CRYPTO_THREAD_lock_new();
-    if (ret->lock == NULL) {
-        ERR_raise(ERR_LIB_USER, ERR_R_MALLOC_FAILURE);
+    if (!CRYPTO_NEW_REF(&ret->references, 1)) {
         OPENSSL_free(ret);
         return NULL;
     }
@@ -707,7 +703,7 @@ static void xor_freekey(void *keydata)
     if (key == NULL)
         return;
 
-    if (CRYPTO_DOWN_REF(&key->references, &refcnt, key->lock) <= 0)
+    if (CRYPTO_DOWN_REF(&key->references, &refcnt) <= 0)
         return;
 
     if (refcnt > 0)
@@ -718,7 +714,7 @@ static void xor_freekey(void *keydata)
         OPENSSL_free(key->tls_name);
         key->tls_name = NULL;
     }
-    CRYPTO_THREAD_lock_free(key->lock);
+    CRYPTO_FREE_REF(&key->references);
     OPENSSL_free(key);
 }
 
@@ -726,7 +722,7 @@ static int xor_key_up_ref(XORKEY *key)
 {
     int refcnt;
 
-    if (CRYPTO_UP_REF(&key->references, &refcnt, key->lock) <= 0)
+    if (CRYPTO_UP_REF(&key->references, &refcnt) <= 0)
         return 0;
 
     assert(refcnt > 1);