diff options
author | Richard Levitte <levitte@openssl.org> | 2016-07-19 19:42:11 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2016-07-19 23:49:54 +0200 |
commit | c2e4e5d248567d4eea5bf6d525bdbcc09099ba6e (patch) | |
tree | e4e16df15de0263a21427c92ae21d20dc98e3c19 /ssl/ssl_cert.c | |
parent | 925d17f3ee4b7f7881fa77a31524ecd9f1305242 (diff) |
Change all our uses of CRYPTO_THREAD_run_once to use RUN_ONCE instead
That way, we have a way to check if the init function was successful
or not.
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Diffstat (limited to 'ssl/ssl_cert.c')
-rw-r--r-- | ssl/ssl_cert.c | 7 |
1 files changed, 5 insertions, 2 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; } |