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 /crypto/bio/b_addr.c | |
parent | 925d17f3ee4b7f7881fa77a31524ecd9f1305242 (diff) | |
download | openssl-c2e4e5d248567d4eea5bf6d525bdbcc09099ba6e.tar.gz |
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/bio/b_addr.c')
-rw-r--r-- | crypto/bio/b_addr.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/crypto/bio/b_addr.c b/crypto/bio/b_addr.c index b77fd4b1a0..4e8785fdcd 100644 --- a/crypto/bio/b_addr.c +++ b/crypto/bio/b_addr.c @@ -15,6 +15,7 @@ #ifndef OPENSSL_NO_SOCK #include <openssl/err.h> #include <openssl/buffer.h> +#include <internal/thread_once.h> #include <ctype.h> CRYPTO_RWLOCK *bio_lookup_lock; @@ -601,9 +602,10 @@ static int addrinfo_wrap(int family, int socktype, return 1; } -static void do_bio_lookup_init(void) +DEFINE_RUN_ONCE_STATIC(do_bio_lookup_init) { bio_lookup_lock = CRYPTO_THREAD_lock_new(); + return (bio_lookup_lock != NULL); } /*- @@ -727,7 +729,11 @@ int BIO_lookup(const char *host, const char *service, struct servent se_fallback = { NULL, NULL, 0, NULL }; #endif - CRYPTO_THREAD_run_once(&bio_lookup_init, do_bio_lookup_init); + if (!RUN_ONCE(&bio_lookup_init, do_bio_lookup_init)) { + BIOerr(BIO_F_BIO_LOOKUP, ERR_R_MALLOC_FAILURE); + ret = 0; + goto err; + } CRYPTO_THREAD_write_lock(bio_lookup_lock); he_fallback_address = INADDR_ANY; |