diff options
Diffstat (limited to 'ssl')
-rw-r--r-- | ssl/ssl_cert.c | 7 | ||||
-rw-r--r-- | ssl/ssl_ciph.c | 7 | ||||
-rw-r--r-- | ssl/ssl_init.c | 19 |
3 files changed, 19 insertions, 14 deletions
diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c index 2a07ee6910..c155e787d5 100644 --- a/ssl/ssl_cert.c +++ b/ssl/ssl_cert.c @@ -29,6 +29,7 @@ #include <openssl/bn.h> #include <openssl/crypto.h> #include "ssl_locl.h" +#include "internal/thread_once.h" static int ssl_security_default_callback(const SSL *s, const SSL_CTX *ctx, int op, int bits, int nid, void *other, @@ -37,17 +38,19 @@ static int ssl_security_default_callback(const SSL *s, const SSL_CTX *ctx, int o static CRYPTO_ONCE ssl_x509_store_ctx_once = CRYPTO_ONCE_STATIC_INIT; static volatile int ssl_x509_store_ctx_idx = -1; -static void ssl_x509_store_ctx_init(void) +DEFINE_RUN_ONCE_STATIC(ssl_x509_store_ctx_init) { ssl_x509_store_ctx_idx = X509_STORE_CTX_get_ex_new_index(0, "SSL for verify callback", NULL, NULL, NULL); + return ssl_x509_store_ctx_idx >= 0; } int SSL_get_ex_data_X509_STORE_CTX_idx(void) { - CRYPTO_THREAD_run_once(&ssl_x509_store_ctx_once, ssl_x509_store_ctx_init); + if (!RUN_ONCE(&ssl_x509_store_ctx_once, ssl_x509_store_ctx_init)) + return -1; return ssl_x509_store_ctx_idx; } diff --git a/ssl/ssl_ciph.c b/ssl/ssl_ciph.c index 2fc4309a91..2a54f9d44d 100644 --- a/ssl/ssl_ciph.c +++ b/ssl/ssl_ciph.c @@ -46,6 +46,7 @@ #include <openssl/engine.h> #include <openssl/crypto.h> #include "ssl_locl.h" +#include "internal/thread_once.h" #define SSL_ENC_DES_IDX 0 #define SSL_ENC_3DES_IDX 1 @@ -479,7 +480,7 @@ static int sk_comp_cmp(const SSL_COMP *const *a, const SSL_COMP *const *b) return ((*a)->id - (*b)->id); } -static void do_load_builtin_compressions(void) +DEFINE_RUN_ONCE_STATIC(do_load_builtin_compressions) { SSL_COMP *comp = NULL; COMP_METHOD *method = COMP_zlib(); @@ -498,12 +499,12 @@ static void do_load_builtin_compressions(void) } } CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE); + return 1; } static void load_builtin_compressions(void) { - CRYPTO_THREAD_run_once(&ssl_load_builtin_comp_once, - do_load_builtin_compressions); + RUN_ONCE(&ssl_load_builtin_comp_once, do_load_builtin_compressions); } #endif diff --git a/ssl/ssl_init.c b/ssl/ssl_init.c index 66525de6c5..543da13339 100644 --- a/ssl/ssl_init.c +++ b/ssl/ssl_init.c @@ -14,6 +14,7 @@ #include <openssl/evp.h> #include <assert.h> #include "ssl_locl.h" +#include "internal/thread_once.h" static int stopped; @@ -21,7 +22,7 @@ static void ssl_library_stop(void); static CRYPTO_ONCE ssl_base = CRYPTO_ONCE_STATIC_INIT; static int ssl_base_inited = 0; -static void ossl_init_ssl_base(void) +DEFINE_RUN_ONCE_STATIC(ossl_init_ssl_base) { #ifdef OPENSSL_INIT_DEBUG fprintf(stderr, "OPENSSL_INIT: ossl_init_ssl_base: " @@ -108,11 +109,12 @@ static void ossl_init_ssl_base(void) */ OPENSSL_atexit(ssl_library_stop); ssl_base_inited = 1; + return 1; } static CRYPTO_ONCE ssl_strings = CRYPTO_ONCE_STATIC_INIT; static int ssl_strings_inited = 0; -static void ossl_init_load_ssl_strings(void) +DEFINE_RUN_ONCE_STATIC(ossl_init_load_ssl_strings) { /* * OPENSSL_NO_AUTOERRINIT is provided here to prevent at compile time @@ -126,12 +128,13 @@ static void ossl_init_load_ssl_strings(void) ERR_load_SSL_strings(); #endif ssl_strings_inited = 1; + return 1; } -static void ossl_init_no_load_ssl_strings(void) +DEFINE_RUN_ONCE_STATIC(ossl_init_no_load_ssl_strings) { /* Do nothing in this case */ - return; + return 1; } static void ssl_library_stop(void) @@ -193,17 +196,15 @@ int OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings) | OPENSSL_INIT_ADD_ALL_DIGESTS, settings)) return 0; - if (!CRYPTO_THREAD_run_once(&ssl_base, ossl_init_ssl_base)) + if (!RUN_ONCE(&ssl_base, ossl_init_ssl_base)) return 0; if ((opts & OPENSSL_INIT_NO_LOAD_SSL_STRINGS) - && !CRYPTO_THREAD_run_once(&ssl_strings, - ossl_init_no_load_ssl_strings)) + && !RUN_ONCE(&ssl_strings, ossl_init_no_load_ssl_strings)) return 0; if ((opts & OPENSSL_INIT_LOAD_SSL_STRINGS) - && !CRYPTO_THREAD_run_once(&ssl_strings, - ossl_init_load_ssl_strings)) + && !RUN_ONCE(&ssl_strings, ossl_init_load_ssl_strings)) return 0; return 1; |