From: Pauli Date: Wed, 21 Jun 2023 23:36:37 +0000 (+1000) Subject: store: update to structure based atomics X-Git-Tag: openssl-3.2.0-alpha1~550 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2a1f467cb9e00d7b6c437443d6414370f3e6ff40;p=thirdparty%2Fopenssl.git store: 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/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; }