diff options
author | beck <> | 2017-04-29 21:54:54 +0000 |
---|---|---|
committer | beck <> | 2017-04-29 21:54:54 +0000 |
commit | 9dda2cefb5b2f181a7789658adadcc6a34dffa6f (patch) | |
tree | f35f76db97fdaee68e44dd170e8839bbb9ab7640 | |
parent | b06d97dea79680706abbabd672be9d0fb4582be7 (diff) | |
download | openbsd-9dda2cefb5b2f181a7789658adadcc6a34dffa6f.tar.gz openbsd-9dda2cefb5b2f181a7789658adadcc6a34dffa6f.tar.bz2 openbsd-9dda2cefb5b2f181a7789658adadcc6a34dffa6f.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@
-rw-r--r-- | src/lib/libssl/ssl_algs.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/lib/libssl/ssl_algs.c b/src/lib/libssl/ssl_algs.c index efbf1a4f31..ab88b29cc1 100644 --- a/src/lib/libssl/ssl_algs.c +++ b/src/lib/libssl/ssl_algs.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_algs.c,v 1.24 2017/03/01 14:01:24 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_algs.c,v 1.25 2017/04/29 21:54:54 beck Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -60,13 +60,15 @@ | |||
60 | 60 | ||
61 | #include <openssl/lhash.h> | 61 | #include <openssl/lhash.h> |
62 | #include <openssl/objects.h> | 62 | #include <openssl/objects.h> |
63 | #include <pthread.h> | ||
63 | 64 | ||
64 | #include "ssl_locl.h" | 65 | #include "ssl_locl.h" |
65 | 66 | ||
66 | int | 67 | pthread_once_t SSL_library_init_once = PTHREAD_ONCE_INIT; |
67 | SSL_library_init(void) | ||
68 | { | ||
69 | 68 | ||
69 | static void | ||
70 | SSL_library_init_internal(void) | ||
71 | { | ||
70 | #ifndef OPENSSL_NO_DES | 72 | #ifndef OPENSSL_NO_DES |
71 | EVP_add_cipher(EVP_des_cbc()); | 73 | EVP_add_cipher(EVP_des_cbc()); |
72 | EVP_add_cipher(EVP_des_ede3_cbc()); | 74 | EVP_add_cipher(EVP_des_ede3_cbc()); |
@@ -125,6 +127,11 @@ SSL_library_init(void) | |||
125 | #endif | 127 | #endif |
126 | /* initialize cipher/digest methods table */ | 128 | /* initialize cipher/digest methods table */ |
127 | ssl_load_ciphers(); | 129 | ssl_load_ciphers(); |
128 | return (1); | ||
129 | } | 130 | } |
130 | 131 | ||
132 | int | ||
133 | SSL_library_init(void) | ||
134 | { | ||
135 | pthread_once(&SSL_library_init_once, SSL_library_init_internal); | ||
136 | return 1; | ||
137 | } | ||