From 59a967030ec1cccf6eb4031a4531c8f555a393ec Mon Sep 17 00:00:00 2001 From: Pauli Date: Thu, 22 Jun 2023 09:37:23 +1000 Subject: [PATCH] test: update to structure based atomics Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/21260) --- test/tls-provider.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/test/tls-provider.c b/test/tls-provider.c index 6c7cd2a2af1..39dde831f48 100644 --- a/test/tls-provider.c +++ b/test/tls-provider.c @@ -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); -- 2.47.2