From 6870c1e7b79043a9a85b70de7b2b29276aff235c Mon Sep 17 00:00:00 2001 From: "Randall S. Becker" Date: Wed, 23 Jun 2021 14:50:09 -0600 Subject: [PATCH] Defined out MUTEX attributes not available on NonStop SPT Threads. Standard Posix Threads (SPT) Threads are an older separate branch of pthreads that do not support some of the capabilities in the current Posix User Threads (PUT). The change also includes a rename of the close field of OSSL_STORE_LOADER which was causing preprocessor conflicts. Fixes #15885 Signed-off-by: Randall S. Becker Reviewed-by: Tomas Mraz Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/15886) --- crypto/store/store_lib.c | 2 +- crypto/store/store_local.h | 2 +- crypto/store/store_register.c | 8 ++++---- crypto/threads_pthread.c | 8 ++++++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/crypto/store/store_lib.c b/crypto/store/store_lib.c index 636a94e832..7dcb939066 100644 --- a/crypto/store/store_lib.c +++ b/crypto/store/store_lib.c @@ -514,7 +514,7 @@ static int ossl_store_close_it(OSSL_STORE_CTX *ctx) ret = ctx->loader->p_close(ctx->loader_ctx); #ifndef OPENSSL_NO_DEPRECATED_3_0 if (ctx->fetched_loader == NULL) - ret = ctx->loader->close(ctx->loader_ctx); + ret = ctx->loader->closefn(ctx->loader_ctx); #endif sk_OSSL_STORE_INFO_pop_free(ctx->cached_info, OSSL_STORE_INFO_free); diff --git a/crypto/store/store_local.h b/crypto/store/store_local.h index 6aeaaa915f..8f817fd514 100644 --- a/crypto/store/store_local.h +++ b/crypto/store/store_local.h @@ -92,7 +92,7 @@ struct ossl_store_loader_st { OSSL_STORE_load_fn load; OSSL_STORE_eof_fn eof; OSSL_STORE_error_fn error; - OSSL_STORE_close_fn close; + OSSL_STORE_close_fn closefn; OSSL_STORE_open_ex_fn open_ex; #endif diff --git a/crypto/store/store_register.c b/crypto/store/store_register.c index dfb0cdc811..6fa7352ccd 100644 --- a/crypto/store/store_register.c +++ b/crypto/store/store_register.c @@ -130,7 +130,7 @@ int OSSL_STORE_LOADER_set_error(OSSL_STORE_LOADER *loader, int OSSL_STORE_LOADER_set_close(OSSL_STORE_LOADER *loader, OSSL_STORE_close_fn close_function) { - loader->close = close_function; + loader->closefn = close_function; return 1; } @@ -185,7 +185,7 @@ int ossl_store_register_loader_int(OSSL_STORE_LOADER *loader) /* Check that functions we absolutely require are present */ if (loader->open == NULL || loader->load == NULL || loader->eof == NULL - || loader->error == NULL || loader->close == NULL) { + || loader->error == NULL || loader->closefn == NULL) { ERR_raise(ERR_LIB_OSSL_STORE, OSSL_STORE_R_LOADER_INCOMPLETE); return 0; } @@ -220,7 +220,7 @@ const OSSL_STORE_LOADER *ossl_store_get0_loader_int(const char *scheme) template.open = NULL; template.load = NULL; template.eof = NULL; - template.close = NULL; + template.closefn = NULL; template.open_ex = NULL; if (!RUN_ONCE(®istry_init, do_registry_init)) { @@ -251,7 +251,7 @@ OSSL_STORE_LOADER *ossl_store_unregister_loader_int(const char *scheme) template.open = NULL; template.load = NULL; template.eof = NULL; - template.close = NULL; + template.closefn = NULL; if (!RUN_ONCE(®istry_init, do_registry_init)) { ERR_raise(ERR_LIB_OSSL_STORE, ERR_R_MALLOC_FAILURE); diff --git a/crypto/threads_pthread.c b/crypto/threads_pthread.c index 00a98f4c71..9f00d8be5e 100644 --- a/crypto/threads_pthread.c +++ b/crypto/threads_pthread.c @@ -57,10 +57,14 @@ CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void) * We don't use recursive mutexes, but try to catch errors if we do. */ pthread_mutexattr_init(&attr); -# if !defined(NDEBUG) && !defined(OPENSSL_NO_MUTEX_ERRORCHECK) +# if !defined (__TANDEM) && !defined (_SPT_MODEL_) +# if !defined(NDEBUG) && !defined(OPENSSL_NO_MUTEX_ERRORCHECK) pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); -# else +# else pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL); +# endif +# else + /* The SPT Thread Library does not define MUTEX attributes. */ # endif if (pthread_mutex_init(lock, &attr) != 0) { -- 2.39.2