mirror of
https://github.com/openssl/openssl.git
synced 2025-01-18 13:44:20 +08:00
Add test for releasing a shared EVP_PKEY across threads
Reviewed-by: Neil Horman <nhorman@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/25664)
This commit is contained in:
parent
c4b30d9c6d
commit
420d5d6294
@ -1014,6 +1014,45 @@ static int test_multi_shared_pkey(void)
|
||||
return test_multi_shared_pkey_common(&thread_shared_evp_pkey);
|
||||
}
|
||||
|
||||
static void thread_release_shared_pkey(void)
|
||||
{
|
||||
OSSL_sleep(0);
|
||||
EVP_PKEY_free(shared_evp_pkey);
|
||||
}
|
||||
|
||||
static int test_multi_shared_pkey_release(void)
|
||||
{
|
||||
int testresult = 0;
|
||||
size_t i = 1;
|
||||
|
||||
multi_intialise();
|
||||
shared_evp_pkey = NULL;
|
||||
if (!thread_setup_libctx(1, do_fips ? fips_and_default_providers
|
||||
: default_provider)
|
||||
|| !TEST_ptr(shared_evp_pkey = load_pkey_pem(privkey, multi_libctx)))
|
||||
goto err;
|
||||
for (; i < 10; ++i) {
|
||||
if (!TEST_true(EVP_PKEY_up_ref(shared_evp_pkey)))
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!start_threads(10, &thread_release_shared_pkey))
|
||||
goto err;
|
||||
i = 0;
|
||||
|
||||
if (!teardown_threads()
|
||||
|| !TEST_true(multi_success))
|
||||
goto err;
|
||||
testresult = 1;
|
||||
err:
|
||||
while (i > 0) {
|
||||
EVP_PKEY_free(shared_evp_pkey);
|
||||
--i;
|
||||
}
|
||||
thead_teardown_libctx();
|
||||
return testresult;
|
||||
}
|
||||
|
||||
static int test_multi_load_unload_provider(void)
|
||||
{
|
||||
EVP_MD *sha256 = NULL;
|
||||
@ -1306,6 +1345,7 @@ int setup_tests(void)
|
||||
#ifndef OPENSSL_NO_DEPRECATED_3_0
|
||||
ADD_TEST(test_multi_downgrade_shared_pkey);
|
||||
#endif
|
||||
ADD_TEST(test_multi_shared_pkey_release);
|
||||
ADD_TEST(test_multi_load_unload_provider);
|
||||
ADD_TEST(test_obj_add);
|
||||
#if !defined(OPENSSL_NO_DGRAM) && !defined(OPENSSL_NO_SOCK)
|
||||
|
Loading…
Reference in New Issue
Block a user