diff options
author | Alessandro Ghedini <alessandro@ghedini.me> | 2016-02-29 17:26:07 +0000 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2016-03-08 18:48:38 -0500 |
commit | 16203f7b71bd343550f89f266eaf9fb9693f6148 (patch) | |
tree | 08a0080d1a26dc6db34c0c28387c99da44744de1 /test | |
parent | be1251f73def8169b98d53430b631df13d430dbc (diff) |
Convert CRYPTO_LOCK_SSL_* to new multi-threading API
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/ssltest.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/test/ssltest.c b/test/ssltest.c index 2ca4d69558..94aeebe9c0 100644 --- a/test/ssltest.c +++ b/test/ssltest.c @@ -191,6 +191,7 @@ # include <openssl/ct.h> #endif +#include "internal/threads.h" #include "../ssl/ssl_locl.h" /* @@ -2949,19 +2950,21 @@ int doit(SSL *s_ssl, SSL *c_ssl, long count) return (ret); } +static CRYPTO_ONCE proxy_auth_ex_data_once = CRYPTO_ONCE_STATIC_INIT; +static volatile int proxy_auth_ex_data_idx = -1; + +static void do_get_proxy_auth_ex_data_idx(void) +{ + proxy_auth_ex_data_idx = X509_STORE_CTX_get_ex_new_index(0, + "SSLtest for verify callback", + NULL, NULL, NULL); +} + static int get_proxy_auth_ex_data_idx(void) { - static volatile int idx = -1; - if (idx < 0) { - CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); - if (idx < 0) { - idx = X509_STORE_CTX_get_ex_new_index(0, - "SSLtest for verify callback", - NULL, NULL, NULL); - } - CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX); - } - return idx; + CRYPTO_THREAD_run_once(&proxy_auth_ex_data_once, + do_get_proxy_auth_ex_data_idx); + return proxy_auth_ex_data_idx; } static int verify_callback(int ok, X509_STORE_CTX *ctx) |