summaryrefslogtreecommitdiffstats
path: root/crypto/core_fetch.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/core_fetch.c')
-rw-r--r--crypto/core_fetch.c46
1 files changed, 20 insertions, 26 deletions
diff --git a/crypto/core_fetch.c b/crypto/core_fetch.c
index 0c30f985d6..fade75f4c9 100644
--- a/crypto/core_fetch.c
+++ b/crypto/core_fetch.c
@@ -83,19 +83,25 @@ static void ossl_method_construct_this(OSSL_PROVIDER *provider,
*/
if (data->force_store || !no_store) {
+ /* If we haven't been told not to store, add to the global store */
+ data->mcm->put(data->libctx, NULL, method, provider,
+ data->operation_id, algo->algorithm_names,
+ algo->property_definition, data->mcm_data);
+ } else {
/*
- * If we haven't been told not to store,
- * add to the global store
+ * If we have been told not to store the method "permanently", we
+ * ask for a temporary store, and store the method there.
+ * The owner of |data->mcm| is completely responsible for managing
+ * that temporary store.
*/
- data->mcm->put(data->libctx, NULL, method, provider,
+ if ((data->store = data->mcm->get_tmp_store(data->mcm_data)) == NULL)
+ return;
+
+ data->mcm->put(data->libctx, data->store, method, provider,
data->operation_id, algo->algorithm_names,
algo->property_definition, data->mcm_data);
}
- data->mcm->put(data->libctx, data->store, method, provider,
- data->operation_id, algo->algorithm_names,
- algo->property_definition, data->mcm_data);
-
/* refcnt-- because we're dropping the reference */
data->mcm->destruct(method, data->mcm_data);
}
@@ -109,14 +115,8 @@ void *ossl_method_construct(OSSL_LIB_CTX *libctx, int operation_id,
if ((method = mcm->get(libctx, NULL, mcm_data)) == NULL) {
struct construct_data_st cbdata;
- /*
- * We have a temporary store to be able to easily search among new
- * items, or items that should find themselves in the global store.
- */
- if ((cbdata.store = mcm->alloc_tmp_store(libctx)) == NULL)
- goto fin;
-
cbdata.libctx = libctx;
+ cbdata.store = NULL;
cbdata.operation_id = operation_id;
cbdata.force_store = force_store;
cbdata.mcm = mcm;
@@ -127,20 +127,14 @@ void *ossl_method_construct(OSSL_LIB_CTX *libctx, int operation_id,
ossl_method_construct_postcondition,
&cbdata);
- method = mcm->get(libctx, cbdata.store, mcm_data);
- if (method == NULL) {
- /*
- * If we get here then we did not construct the method that we
- * attempted to construct. It's possible that another thread got
- * there first and so we skipped construction (pre-condition
- * failed). We check the global store again to see if it has
- * appeared by now.
- */
+ /* If there is a temporary store, try there first */
+ if (cbdata.store != NULL)
+ method = mcm->get(libctx, cbdata.store, mcm_data);
+
+ /* If no method was found yet, try the global store */
+ if (method == NULL)
method = mcm->get(libctx, NULL, mcm_data);
- }
- mcm->dealloc_tmp_store(cbdata.store);
}
- fin:
return method;
}