diff options
author | Pauli <pauli@openssl.org> | 2023-06-22 09:37:23 +1000 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2023-07-01 21:18:25 +1000 |
commit | 59a967030ec1cccf6eb4031a4531c8f555a393ec (patch) | |
tree | ed2e45f5ecfa327d6a3c1a053368a3477322fb65 | |
parent | 2a1f467cb9e00d7b6c437443d6414370f3e6ff40 (diff) |
test: update to structure based atomics
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21260)
-rw-r--r-- | test/tls-provider.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/test/tls-provider.c b/test/tls-provider.c index 6c7cd2a2af..39dde831f4 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); |