Convert CRYPTO_LOCK_UI to new multi-threading API

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
This commit is contained in:
Alessandro Ghedini
2016-02-29 17:12:25 +00:00
committed by Rich Salz
parent 9b398ef297
commit 41cfbccc99
4 changed files with 13 additions and 3 deletions

View File

@@ -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);
}

View File

@@ -139,6 +139,8 @@ struct ui_st {
# define UI_FLAG_REDOABLE 0x0001
# define UI_FLAG_PRINT_ERRORS 0x0100
int flags;
CRYPTO_RWLOCK *lock;
};
#endif

View File

@@ -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;
}

View File

@@ -185,7 +185,6 @@ extern "C" {
# define CRYPTO_LOCK_MALLOC2 27
# define CRYPTO_LOCK_DYNLOCK 29
# define CRYPTO_LOCK_ENGINE 30
# define CRYPTO_LOCK_UI 31
# define CRYPTO_LOCK_ECDSA 32
# define CRYPTO_LOCK_ECDH 34
# define CRYPTO_LOCK_BN 35