diff options
author | Pauli <pauli@openssl.org> | 2022-01-12 14:22:23 +1100 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2022-01-13 21:46:34 +1100 |
commit | d8ed9e4a9079b55a84bdbbc3172d36aa3be8bed7 (patch) | |
tree | 862e528e5772b385af85eff58af72431d06d2b80 /crypto | |
parent | e22cbe5e67461470590e6fb8858c95285fcdea0e (diff) |
core namemap: use updated tsan lock detection capabilities
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/17479)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/core_namemap.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/crypto/core_namemap.c b/crypto/core_namemap.c index 2bee5ef194..6cb0ec5a06 100644 --- a/crypto/core_namemap.c +++ b/crypto/core_namemap.c @@ -37,11 +37,7 @@ struct ossl_namemap_st { CRYPTO_RWLOCK *lock; LHASH_OF(NAMENUM_ENTRY) *namenum; /* Name->number mapping */ -#ifdef tsan_ld_acq - TSAN_QUALIFIER int max_number; /* Current max number TSAN version */ -#else - int max_number; /* Current max number plain version */ -#endif + TSAN_QUALIFIER int max_number; /* Current max number */ }; /* LHASH callbacks */ @@ -99,10 +95,7 @@ static const OSSL_LIB_CTX_METHOD stored_namemap_method = { int ossl_namemap_empty(OSSL_NAMEMAP *namemap) { -#ifdef tsan_ld_acq - /* Have TSAN support */ - return namemap == NULL || tsan_load(&namemap->max_number) == 0; -#else +#ifdef TSAN_REQUIRES_LOCKING /* No TSAN support */ int rv; @@ -114,6 +107,9 @@ int ossl_namemap_empty(OSSL_NAMEMAP *namemap) rv = namemap->max_number == 0; CRYPTO_THREAD_unlock(namemap->lock); return rv; +#else + /* Have TSAN support */ + return namemap == NULL || tsan_load(&namemap->max_number) == 0; #endif } @@ -260,6 +256,7 @@ static int namemap_add_name_n(OSSL_NAMEMAP *namemap, int number, || (namenum->name = OPENSSL_strndup(name, name_len)) == NULL) goto err; + /* The tsan_counter use here is safe since we're under lock */ namenum->number = number != 0 ? number : 1 + tsan_counter(&namemap->max_number); (void)lh_NAMENUM_ENTRY_insert(namemap->namenum, namenum); |