From: Pauli Date: Wed, 21 Jun 2023 23:37:23 +0000 (+1000) Subject: test: update to structure based atomics X-Git-Tag: openssl-3.2.0-alpha1~549 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=59a967030ec1cccf6eb4031a4531c8f555a393ec;p=thirdparty%2Fopenssl.git test: update to structure based atomics Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/21260) --- 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);