From 2a1f467cb9e00d7b6c437443d6414370f3e6ff40 Mon Sep 17 00:00:00 2001 From: Pauli Date: Thu, 22 Jun 2023 09:36:37 +1000 Subject: [PATCH] store: update to structure based atomics Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/21260) --- crypto/store/store_local.h | 1 - crypto/store/store_meth.c | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/crypto/store/store_local.h b/crypto/store/store_local.h index bca6516b04e..6526a7260a0 100644 --- a/crypto/store/store_local.h +++ b/crypto/store/store_local.h @@ -103,7 +103,6 @@ struct ossl_store_loader_st { const char *description; CRYPTO_REF_COUNT refcnt; - CRYPTO_RWLOCK *lock; OSSL_FUNC_store_open_fn *p_open; OSSL_FUNC_store_attach_fn *p_attach; diff --git a/crypto/store/store_meth.c b/crypto/store/store_meth.c index ab1016853e8..e9f5a0eb8ab 100644 --- a/crypto/store/store_meth.c +++ b/crypto/store/store_meth.c @@ -21,7 +21,7 @@ int OSSL_STORE_LOADER_up_ref(OSSL_STORE_LOADER *loader) int ref = 0; if (loader->prov != NULL) - CRYPTO_UP_REF(&loader->refcnt, &ref, loader->lock); + CRYPTO_UP_REF(&loader->refcnt, &ref); return 1; } @@ -30,11 +30,11 @@ void OSSL_STORE_LOADER_free(OSSL_STORE_LOADER *loader) if (loader != NULL && loader->prov != NULL) { int i; - CRYPTO_DOWN_REF(&loader->refcnt, &i, loader->lock); + CRYPTO_DOWN_REF(&loader->refcnt, &i); if (i > 0) return; ossl_provider_free(loader->prov); - CRYPTO_THREAD_lock_free(loader->lock); + CRYPTO_FREE_REF(&loader->refcnt); } OPENSSL_free(loader); } @@ -48,13 +48,12 @@ static OSSL_STORE_LOADER *new_loader(OSSL_PROVIDER *prov) OSSL_STORE_LOADER *loader; if ((loader = OPENSSL_zalloc(sizeof(*loader))) == NULL - || (loader->lock = CRYPTO_THREAD_lock_new()) == NULL) { + || !CRYPTO_NEW_REF(&loader->refcnt, 1)) { OPENSSL_free(loader); return NULL; } loader->prov = prov; ossl_provider_up_ref(prov); - loader->refcnt = 1; return loader; } -- 2.47.2