diff options
author | Matt Caswell <matt@openssl.org> | 2021-05-13 15:35:42 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2021-05-15 10:33:42 +0100 |
commit | 36a89c04390f2d98e740b9c53a1eead9dcb5f188 (patch) | |
tree | 8a895e2e68d24eceaa5a5fda2cf4b85807ffcfd2 /crypto/provider_child.c | |
parent | 773f1c3320f546a53906bd377b2c9d385ece3c39 (diff) |
Init the child providers immediately on creation of the child libctx
We were deferring the initial creation of the child providers until the
first fetch. This is a carry over from an earlier iteration of the child
lib ctx development and is no longer necessary. In fact we need to init
the child providers immediately otherwise not all providers quite init
correctly.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15270)
Diffstat (limited to 'crypto/provider_child.c')
-rw-r--r-- | crypto/provider_child.c | 46 |
1 files changed, 8 insertions, 38 deletions
diff --git a/crypto/provider_child.c b/crypto/provider_child.c index 0ca61c0686..2487d43fd7 100644 --- a/crypto/provider_child.c +++ b/crypto/provider_child.c @@ -198,44 +198,6 @@ static int provider_remove_child_cb(const OSSL_CORE_HANDLE *prov, void *cbdata) return 1; } -int ossl_provider_init_child_providers(OSSL_LIB_CTX *ctx) -{ - struct child_prov_globals *gbl; - - /* Should never happen */ - if (ctx == NULL) - return 0; - - gbl = ossl_lib_ctx_get_data(ctx, OSSL_LIB_CTX_CHILD_PROVIDER_INDEX, - &child_prov_ossl_ctx_method); - if (gbl == NULL) - return 0; - - if (!CRYPTO_THREAD_read_lock(gbl->lock)) - return 0; - if (gbl->isinited) { - CRYPTO_THREAD_unlock(gbl->lock); - return 1; - } - CRYPTO_THREAD_unlock(gbl->lock); - - if (!CRYPTO_THREAD_write_lock(gbl->lock)) - return 0; - if (!gbl->isinited) { - if (!gbl->c_provider_register_child_cb(gbl->handle, - provider_create_child_cb, - provider_remove_child_cb, - ctx)) { - CRYPTO_THREAD_unlock(gbl->lock); - return 0; - } - gbl->isinited = 1; - } - CRYPTO_THREAD_unlock(gbl->lock); - - return 1; -} - int ossl_provider_init_as_child(OSSL_LIB_CTX *ctx, const OSSL_CORE_HANDLE *handle, const OSSL_DISPATCH *in) @@ -300,6 +262,14 @@ int ossl_provider_init_as_child(OSSL_LIB_CTX *ctx, if (gbl->lock == NULL) return 0; + if (!gbl->c_provider_register_child_cb(gbl->handle, + provider_create_child_cb, + provider_remove_child_cb, + ctx)) + return 0; + + gbl->isinited = 1; + return 1; } |