From aaab365c5afb950b9ffaa2916635a18e0d34fa98 Mon Sep 17 00:00:00 2001 From: Pauli Date: Thu, 22 Jun 2023 09:29:24 +1000 Subject: dso: update to structure based atomics Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/21260) --- crypto/dso/dso_lib.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'crypto/dso/dso_lib.c') diff --git a/crypto/dso/dso_lib.c b/crypto/dso/dso_lib.c index a73d91e839..7680c40547 100644 --- a/crypto/dso/dso_lib.c +++ b/crypto/dso/dso_lib.c @@ -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); -- cgit v1.2.3