From 41cfbccc99f3ca3c9f656d8c71e2db5bcfcf6817 Mon Sep 17 00:00:00 2001 From: Alessandro Ghedini Date: Mon, 29 Feb 2016 17:12:25 +0000 Subject: Convert CRYPTO_LOCK_UI to new multi-threading API Reviewed-by: Matt Caswell Reviewed-by: Rich Salz --- crypto/ui/ui_lib.c | 9 +++++++++ crypto/ui/ui_locl.h | 2 ++ crypto/ui/ui_openssl.c | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-) (limited to 'crypto/ui') diff --git a/crypto/ui/ui_lib.c b/crypto/ui/ui_lib.c index 08e6c7be37..7b08107f7a 100644 --- a/crypto/ui/ui_lib.c +++ b/crypto/ui/ui_lib.c @@ -79,6 +79,14 @@ UI *UI_new_method(const UI_METHOD *method) UIerr(UI_F_UI_NEW_METHOD, ERR_R_MALLOC_FAILURE); return NULL; } + + ret->lock = CRYPTO_THREAD_lock_new(); + if (ret->lock == NULL) { + UIerr(UI_F_UI_NEW_METHOD, ERR_R_MALLOC_FAILURE); + OPENSSL_free(ret); + return NULL; + } + if (method == NULL) ret->meth = UI_get_default_method(); else @@ -111,6 +119,7 @@ void UI_free(UI *ui) return; sk_UI_STRING_pop_free(ui->strings, free_string); CRYPTO_free_ex_data(CRYPTO_EX_INDEX_UI, ui, &ui->ex_data); + CRYPTO_THREAD_lock_free(ui->lock); OPENSSL_free(ui); } diff --git a/crypto/ui/ui_locl.h b/crypto/ui/ui_locl.h index 5ed77fada0..abbdd1c0b5 100644 --- a/crypto/ui/ui_locl.h +++ b/crypto/ui/ui_locl.h @@ -139,6 +139,8 @@ struct ui_st { # define UI_FLAG_REDOABLE 0x0001 # define UI_FLAG_PRINT_ERRORS 0x0100 int flags; + + CRYPTO_RWLOCK *lock; }; #endif diff --git a/crypto/ui/ui_openssl.c b/crypto/ui/ui_openssl.c index 9b4786b3b5..9a4870803e 100644 --- a/crypto/ui/ui_openssl.c +++ b/crypto/ui/ui_openssl.c @@ -462,7 +462,7 @@ static int read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl) /* Internal functions to open, handle and close a channel to the console. */ static int open_console(UI *ui) { - CRYPTO_w_lock(CRYPTO_LOCK_UI); + CRYPTO_THREAD_write_lock(ui->lock); is_a_tty = 1; #if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) @@ -569,7 +569,7 @@ static int close_console(UI *ui) #ifdef OPENSSL_SYS_VMS status = sys$dassgn(channel); #endif - CRYPTO_w_unlock(CRYPTO_LOCK_UI); + CRYPTO_THREAD_unlock(ui->lock); return 1; } -- cgit v1.2.3