summaryrefslogtreecommitdiffstats
path: root/crypto/engine/eng_init.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2016-07-19 19:42:11 +0200
committerRichard Levitte <levitte@openssl.org>2016-07-19 23:49:54 +0200
commitc2e4e5d248567d4eea5bf6d525bdbcc09099ba6e (patch)
treee4e16df15de0263a21427c92ae21d20dc98e3c19 /crypto/engine/eng_init.c
parentDefine a few internal macros for easy use of run_once functions (diff)
downloadopenssl-c2e4e5d248567d4eea5bf6d525bdbcc09099ba6e.tar.xz
openssl-c2e4e5d248567d4eea5bf6d525bdbcc09099ba6e.zip
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 'crypto/engine/eng_init.c')
-rw-r--r--crypto/engine/eng_init.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/crypto/engine/eng_init.c b/crypto/engine/eng_init.c
index c51a38dac0..8be7c6fc86 100644
--- a/crypto/engine/eng_init.c
+++ b/crypto/engine/eng_init.c
@@ -80,7 +80,10 @@ int ENGINE_init(ENGINE *e)
ENGINEerr(ENGINE_F_ENGINE_INIT, ERR_R_PASSED_NULL_PARAMETER);
return 0;
}
- CRYPTO_THREAD_run_once(&engine_lock_init, do_engine_lock_init);
+ if (!RUN_ONCE(&engine_lock_init, do_engine_lock_init)) {
+ ENGINEerr(ENGINE_F_ENGINE_INIT, ERR_R_MALLOC_FAILURE);
+ return 0;
+ }
CRYPTO_THREAD_write_lock(global_engine_lock);
ret = engine_unlocked_init(e);
CRYPTO_THREAD_unlock(global_engine_lock);