Add functions supporting thread pool only when it is enabled

Fixes #19691

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19695)
This commit is contained in:
Tomas Mraz 2022-11-16 14:51:48 +01:00
parent 26cfa4cd85
commit f5a3669c8b
4 changed files with 8 additions and 25 deletions

View File

@ -174,7 +174,7 @@ static int context_init(OSSL_LIB_CTX *ctx)
goto err;
#endif
#if defined(OPENSSL_THREADS)
#ifndef OPENSSL_NO_THREAD_POOL
ctx->threads = ossl_threads_ctx_new(ctx);
if (ctx->threads == NULL)
goto err;
@ -308,7 +308,7 @@ static void context_deinit_objs(OSSL_LIB_CTX *ctx)
}
#endif
#if defined(OPENSSL_THREADS)
#ifndef OPENSSL_NO_THREAD_POOL
if (ctx->threads != NULL) {
ossl_threads_ctx_free(ctx->threads);
ctx->threads = NULL;
@ -551,7 +551,7 @@ void *ossl_lib_ctx_get_data(OSSL_LIB_CTX *ctx, int index)
case OSSL_LIB_CTX_SELF_TEST_CB_INDEX:
return ctx->self_test_cb;
#endif
#if defined(OPENSSL_THREADS)
#ifndef OPENSSL_NO_THREAD_POOL
case OSSL_LIB_CTX_THREAD_INDEX:
return ctx->threads;
#endif

View File

@ -10,8 +10,6 @@
#include <openssl/configuration.h>
#include <internal/thread_arch.h>
#if defined(OPENSSL_THREADS)
CRYPTO_THREAD *ossl_crypto_thread_native_start(CRYPTO_THREAD_ROUTINE routine,
void *data, int joinable)
{
@ -133,18 +131,3 @@ int ossl_crypto_thread_native_clean(CRYPTO_THREAD *handle)
return 1;
}
#else
CRYPTO_THREAD *ossl_crypto_thread_native_start(CRYPTO_THREAD_ROUTINE routine,
void *data, int joinable)
{
return NULL;
}
int ossl_crypto_thread_native_clean(CRYPTO_THREAD *handle)
{
return 0;
}
#endif

View File

@ -1,8 +1,12 @@
LIBS=../../libcrypto
$THREADS=\
IF[{- !$disabled{'thread-pool'} -}]
$THREADS=\
api.c internal.c arch.c \
arch/thread_win.c arch/thread_posix.c arch/thread_none.c
ELSE
$THREADS=api.c
ENDIF
SOURCE[../../libcrypto]=$THREADS
SOURCE[../../providers/libfips.a]=$THREADS

View File

@ -124,8 +124,6 @@ int ossl_crypto_thread_clean(void *vhandle)
#endif
#if defined(OPENSSL_THREADS)
void *ossl_threads_ctx_new(OSSL_LIB_CTX *ctx)
{
struct openssl_threads_st *t = OPENSSL_zalloc(sizeof(*t));
@ -157,5 +155,3 @@ void ossl_threads_ctx_free(void *vdata)
ossl_crypto_condvar_free(&t->cond_finished);
OPENSSL_free(t);
}
#endif