Browse Source

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)
Tomas Mraz 1 year ago
parent
commit
f5a3669c8b
4 changed files with 8 additions and 25 deletions
  1. 3 3
      crypto/context.c
  2. 0 17
      crypto/thread/arch.c
  3. 5 1
      crypto/thread/build.info
  4. 0 4
      crypto/thread/internal.c

+ 3 - 3
crypto/context.c

@@ -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

+ 0 - 17
crypto/thread/arch.c

@@ -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

+ 5 - 1
crypto/thread/build.info

@@ -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

+ 0 - 4
crypto/thread/internal.c

@@ -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