projects
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix no-ocsp
[openssl.git]
/
crypto
/
err
/
err.c
diff --git
a/crypto/err/err.c
b/crypto/err/err.c
index 36ba9c74effa445b70a6e6681966e24c80a9b876..da6d3ee981c5ad5268d790e4d57115b4f5813366 100644
(file)
--- a/
crypto/err/err.c
+++ b/
crypto/err/err.c
@@
-234,6
+234,9
@@
static ERR_STRING_DATA ERR_str_reasons[] = {
static CRYPTO_ONCE err_init = CRYPTO_ONCE_STATIC_INIT;
static CRYPTO_THREAD_LOCAL err_thread_local;
static CRYPTO_ONCE err_init = CRYPTO_ONCE_STATIC_INIT;
static CRYPTO_THREAD_LOCAL err_thread_local;
+static CRYPTO_ONCE err_string_init = CRYPTO_ONCE_STATIC_INIT;
+static CRYPTO_RWLOCK *err_string_lock;
+
/* Predeclarations of the "err_defaults" functions */
static LHASH_OF(ERR_STRING_DATA) *get_hash(int create, int lockit);
static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *);
/* Predeclarations of the "err_defaults" functions */
static LHASH_OF(ERR_STRING_DATA) *get_hash(int create, int lockit);
static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *);
@@
-269,7
+272,7
@@
static LHASH_OF(ERR_STRING_DATA) *get_hash(int create, int lockit)
LHASH_OF(ERR_STRING_DATA) *ret = NULL;
if (lockit)
LHASH_OF(ERR_STRING_DATA) *ret = NULL;
if (lockit)
- CRYPTO_
w_lock(CRYPTO_LOCK_ERR
);
+ CRYPTO_
THREAD_write_lock(err_string_lock
);
if (!int_error_hash && create) {
int_error_hash = lh_ERR_STRING_DATA_new(err_string_data_hash,
err_string_data_cmp);
if (!int_error_hash && create) {
int_error_hash = lh_ERR_STRING_DATA_new(err_string_data_hash,
err_string_data_cmp);
@@
-277,7
+280,7
@@
static LHASH_OF(ERR_STRING_DATA) *get_hash(int create, int lockit)
if (int_error_hash != NULL)
ret = int_error_hash;
if (lockit)
if (int_error_hash != NULL)
ret = int_error_hash;
if (lockit)
- CRYPTO_
w_unlock(CRYPTO_LOCK_ERR
);
+ CRYPTO_
THREAD_unlock(err_string_lock
);
return ret;
}
return ret;
}
@@
-287,11
+290,11
@@
static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *d)
ERR_STRING_DATA *p = NULL;
LHASH_OF(ERR_STRING_DATA) *hash;
ERR_STRING_DATA *p = NULL;
LHASH_OF(ERR_STRING_DATA) *hash;
- CRYPTO_
r_lock(CRYPTO_LOCK_ERR
);
+ CRYPTO_
THREAD_read_lock(err_string_lock
);
hash = get_hash(0, 0);
if (hash)
p = lh_ERR_STRING_DATA_retrieve(hash, d);
hash = get_hash(0, 0);
if (hash)
p = lh_ERR_STRING_DATA_retrieve(hash, d);
- CRYPTO_
r_unlock(CRYPTO_LOCK_ERR
);
+ CRYPTO_
THREAD_unlock(err_string_lock
);
return p;
}
return p;
}
@@
-318,16
+321,9
@@
static void build_SYS_str_reasons(void)
static int init = 1;
int i;
static int init = 1;
int i;
- CRYPTO_r_lock(CRYPTO_LOCK_ERR);
- if (!init) {
- CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
- return;
- }
-
- CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
- CRYPTO_w_lock(CRYPTO_LOCK_ERR);
+ CRYPTO_THREAD_write_lock(err_string_lock);
if (!init) {
if (!init) {
- CRYPTO_
w_unlock(CRYPTO_LOCK_ERR
);
+ CRYPTO_
THREAD_unlock(err_string_lock
);
return;
}
return;
}
@@
-355,7
+351,7
@@
static void build_SYS_str_reasons(void)
init = 0;
init = 0;
- CRYPTO_
w_unlock(CRYPTO_LOCK_ERR
);
+ CRYPTO_
THREAD_unlock(err_string_lock
);
}
#endif
}
#endif
@@
-391,9
+387,18
@@
static void ERR_STATE_free(ERR_STATE *s)
OPENSSL_free(s);
}
OPENSSL_free(s);
}
+static void do_err_strings_init(void)
+{
+ CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
+ err_string_lock = CRYPTO_THREAD_lock_new();
+ CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
+}
+
void ERR_load_ERR_strings(void)
{
#ifndef OPENSSL_NO_ERR
void ERR_load_ERR_strings(void)
{
#ifndef OPENSSL_NO_ERR
+ CRYPTO_THREAD_run_once(&err_string_init, do_err_strings_init);
+
err_load_strings(0, ERR_str_libraries);
err_load_strings(0, ERR_str_reasons);
err_load_strings(ERR_LIB_SYS, ERR_str_functs);
err_load_strings(0, ERR_str_libraries);
err_load_strings(0, ERR_str_reasons);
err_load_strings(ERR_LIB_SYS, ERR_str_functs);
@@
-406,7
+411,7
@@
static void err_load_strings(int lib, ERR_STRING_DATA *str)
{
LHASH_OF(ERR_STRING_DATA) *hash;
{
LHASH_OF(ERR_STRING_DATA) *hash;
- CRYPTO_
w_lock(CRYPTO_LOCK_ERR
);
+ CRYPTO_
THREAD_write_lock(err_string_lock
);
hash = get_hash(1, 0);
if (hash) {
for (; str->error; str++) {
hash = get_hash(1, 0);
if (hash) {
for (; str->error; str++) {
@@
-415,7
+420,7
@@
static void err_load_strings(int lib, ERR_STRING_DATA *str)
(void)lh_ERR_STRING_DATA_insert(hash, str);
}
}
(void)lh_ERR_STRING_DATA_insert(hash, str);
}
}
- CRYPTO_
w_unlock(CRYPTO_LOCK_ERR
);
+ CRYPTO_
THREAD_unlock(err_string_lock
);
}
void ERR_load_strings(int lib, ERR_STRING_DATA *str)
}
void ERR_load_strings(int lib, ERR_STRING_DATA *str)
@@
-428,7
+433,9
@@
void ERR_unload_strings(int lib, ERR_STRING_DATA *str)
{
LHASH_OF(ERR_STRING_DATA) *hash;
{
LHASH_OF(ERR_STRING_DATA) *hash;
- CRYPTO_w_lock(CRYPTO_LOCK_ERR);
+ CRYPTO_THREAD_run_once(&err_string_init, do_err_strings_init);
+
+ CRYPTO_THREAD_write_lock(err_string_lock);
hash = get_hash(0, 0);
if (hash) {
for (; str->error; str++) {
hash = get_hash(0, 0);
if (hash) {
for (; str->error; str++) {
@@
-437,15
+444,17
@@
void ERR_unload_strings(int lib, ERR_STRING_DATA *str)
(void)lh_ERR_STRING_DATA_delete(hash, str);
}
}
(void)lh_ERR_STRING_DATA_delete(hash, str);
}
}
- CRYPTO_
w_unlock(CRYPTO_LOCK_ERR
);
+ CRYPTO_
THREAD_unlock(err_string_lock
);
}
void ERR_free_strings(void)
{
}
void ERR_free_strings(void)
{
- CRYPTO_w_lock(CRYPTO_LOCK_ERR);
+ CRYPTO_THREAD_run_once(&err_string_init, do_err_strings_init);
+
+ CRYPTO_THREAD_write_lock(err_string_lock);
lh_ERR_STRING_DATA_free(int_error_hash);
int_error_hash = NULL;
lh_ERR_STRING_DATA_free(int_error_hash);
int_error_hash = NULL;
- CRYPTO_
w_unlock(CRYPTO_LOCK_ERR
);
+ CRYPTO_
THREAD_unlock(err_string_lock
);
}
/********************************************************/
}
/********************************************************/
@@
-686,6
+695,8
@@
const char *ERR_lib_error_string(unsigned long e)
ERR_STRING_DATA d, *p;
unsigned long l;
ERR_STRING_DATA d, *p;
unsigned long l;
+ CRYPTO_THREAD_run_once(&err_string_init, do_err_strings_init);
+
l = ERR_GET_LIB(e);
d.error = ERR_PACK(l, 0, 0);
p = int_err_get_item(&d);
l = ERR_GET_LIB(e);
d.error = ERR_PACK(l, 0, 0);
p = int_err_get_item(&d);
@@
-697,6
+708,8
@@
const char *ERR_func_error_string(unsigned long e)
ERR_STRING_DATA d, *p;
unsigned long l, f;
ERR_STRING_DATA d, *p;
unsigned long l, f;
+ CRYPTO_THREAD_run_once(&err_string_init, do_err_strings_init);
+
l = ERR_GET_LIB(e);
f = ERR_GET_FUNC(e);
d.error = ERR_PACK(l, f, 0);
l = ERR_GET_LIB(e);
f = ERR_GET_FUNC(e);
d.error = ERR_PACK(l, f, 0);
@@
-709,6
+722,8
@@
const char *ERR_reason_error_string(unsigned long e)
ERR_STRING_DATA d, *p = NULL;
unsigned long l, r;
ERR_STRING_DATA d, *p = NULL;
unsigned long l, r;
+ CRYPTO_THREAD_run_once(&err_string_init, do_err_strings_init);
+
l = ERR_GET_LIB(e);
r = ERR_GET_REASON(e);
d.error = ERR_PACK(l, 0, r);
l = ERR_GET_LIB(e);
r = ERR_GET_REASON(e);
d.error = ERR_PACK(l, 0, r);
@@
-772,9
+787,11
@@
int ERR_get_next_error_library(void)
{
int ret;
{
int ret;
- CRYPTO_w_lock(CRYPTO_LOCK_ERR);
+ CRYPTO_THREAD_run_once(&err_string_init, do_err_strings_init);
+
+ CRYPTO_THREAD_write_lock(err_string_lock);
ret = int_err_library_number++;
ret = int_err_library_number++;
- CRYPTO_
w_unlock(CRYPTO_LOCK_ERR
);
+ CRYPTO_
THREAD_unlock(err_string_lock
);
return ret;
}
return ret;
}