aboutsummaryrefslogtreecommitdiff
path: root/crypto/ui
diff options
context:
space:
mode:
authorAlessandro Ghedini <alessandro@ghedini.me>2016-02-29 17:12:25 +0000
committerRich Salz <rsalz@openssl.org>2016-03-08 11:10:34 -0500
commit41cfbccc99f3ca3c9f656d8c71e2db5bcfcf6817 (patch)
tree900c46e5cd1506da790f8f49404bcb518a96e1c8 /crypto/ui
parent9b398ef297dd1b74527dd0afee9f59cd3f5bc33d (diff)
downloadopenssl-41cfbccc99f3ca3c9f656d8c71e2db5bcfcf6817.zip
openssl-41cfbccc99f3ca3c9f656d8c71e2db5bcfcf6817.tar.gz
openssl-41cfbccc99f3ca3c9f656d8c71e2db5bcfcf6817.tar.bz2
Convert CRYPTO_LOCK_UI to new multi-threading API
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'crypto/ui')
-rw-r--r--crypto/ui/ui_lib.c9
-rw-r--r--crypto/ui/ui_locl.h2
-rw-r--r--crypto/ui/ui_openssl.c4
3 files changed, 13 insertions, 2 deletions
diff --git a/crypto/ui/ui_lib.c b/crypto/ui/ui_lib.c
index 08e6c7b..7b08107 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 5ed77fa..abbdd1c 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 9b4786b..9a48708 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;
}