diff options
author | 2017-04-29 21:54:54 +0000 | |
---|---|---|
committer | 2017-04-29 21:54:54 +0000 | |
commit | 97fada5536ca3f502088da86e67a8d57dc324ddb (patch) | |
tree | d80f56fb5561d814231f1161ab071060d03088a0 /lib/libssl/ssl_algs.c | |
parent | Stop calling OPENSSL_init() internally, since it is a no-op. Also place (diff) | |
download | wireguard-openbsd-97fada5536ca3f502088da86e67a8d57dc324ddb.tar.xz wireguard-openbsd-97fada5536ca3f502088da86e67a8d57dc324ddb.zip |
Make it safe to call SSL_library_init more than once.
We are basically admitting that pthread is everywhere, and
we will be using it for other things too.
ok jsing@
Diffstat (limited to 'lib/libssl/ssl_algs.c')
-rw-r--r-- | lib/libssl/ssl_algs.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/libssl/ssl_algs.c b/lib/libssl/ssl_algs.c index efbf1a4f310..ab88b29cc16 100644 --- a/lib/libssl/ssl_algs.c +++ b/lib/libssl/ssl_algs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_algs.c,v 1.24 2017/03/01 14:01:24 jsing Exp $ */ +/* $OpenBSD: ssl_algs.c,v 1.25 2017/04/29 21:54:54 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -60,13 +60,15 @@ #include <openssl/lhash.h> #include <openssl/objects.h> +#include <pthread.h> #include "ssl_locl.h" -int -SSL_library_init(void) -{ +pthread_once_t SSL_library_init_once = PTHREAD_ONCE_INIT; +static void +SSL_library_init_internal(void) +{ #ifndef OPENSSL_NO_DES EVP_add_cipher(EVP_des_cbc()); EVP_add_cipher(EVP_des_ede3_cbc()); @@ -125,6 +127,11 @@ SSL_library_init(void) #endif /* initialize cipher/digest methods table */ ssl_load_ciphers(); - return (1); } +int +SSL_library_init(void) +{ + pthread_once(&SSL_library_init_once, SSL_library_init_internal); + return 1; +} |