/* OpenSSL library side data */
CRYPTO_REF_COUNT refcnt;
-#ifndef HAVE_ATOMICS
- CRYPTO_RWLOCK refcnt_lock; /* For the ref counter */
-#endif
+ CRYPTO_RWLOCK *refcnt_lock; /* For the ref counter */
char *name;
DSO *module;
OSSL_provider_init_fn *init_function;
{
int ref = 0;
-#ifndef HAVE_ATOMICS
CRYPTO_UP_REF(&prov->refcnt, &ref, prov->refcnt_lock);
-#else
- CRYPTO_UP_REF(&prov->refcnt, &ref, NULL);
-#endif
return ref;
}
}
if ((prov = OPENSSL_zalloc(sizeof(*prov))) == NULL
+#ifndef HAVE_ATOMICS
+ || (prov->refcnt_lock = CRYPTO_THREAD_lock_new()) == NULL
+#endif
|| !ossl_provider_upref(prov) /* +1 One reference to be returned */
|| (prov->name = OPENSSL_strdup(name)) == NULL) {
ossl_provider_free(prov);
if (prov != NULL) {
int ref = 0;
-#ifndef HAVE_ATOMICS
- CRYPTO_DOWN_REF(&prov->refcnt, &ref, provider_lock);
-#else
- CRYPTO_DOWN_REF(&prov->refcnt, &ref, NULL);
-#endif
+ CRYPTO_DOWN_REF(&prov->refcnt, &ref, prov->refcnt_lock);
/*
* When the refcount drops down to one, there is only one reference,
if (ref == 0) {
DSO_free(prov->module);
OPENSSL_free(prov->name);
+#ifndef HAVE_ATOMICS
+ CRYPTO_THREAD_lock_free(prov->refcnt_lock);
+#endif
OPENSSL_free(prov);
}
}