summaryrefslogtreecommitdiffstats
path: root/crypto/lhash/lhash.c
diff options
context:
space:
mode:
authorAndy Polyakov <appro@openssl.org>2018-07-29 14:11:49 +0200
committerAndy Polyakov <appro@openssl.org>2018-08-07 09:08:18 +0200
commitcab76c0f6482df5140efa2ca93c9e2d972fcd9b0 (patch)
treebc9501103fccc8d91af4a080fa48643d6726de7e /crypto/lhash/lhash.c
parentede3e6653c1127e852493655737327170567a453 (diff)
lhash/lhash.c: switch to Thread-Sanitizer-friendly primitives.
Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/6786)
Diffstat (limited to 'crypto/lhash/lhash.c')
-rw-r--r--crypto/lhash/lhash.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/crypto/lhash/lhash.c b/crypto/lhash/lhash.c
index dca500723d..f7ac9d02f5 100644
--- a/crypto/lhash/lhash.c
+++ b/crypto/lhash/lhash.c
@@ -157,16 +157,18 @@ void *OPENSSL_LH_retrieve(OPENSSL_LHASH *lh, const void *data)
OPENSSL_LH_NODE **rn;
void *ret;
- lh->error = 0;
+ tsan_store((TSAN_QUALIFIER int *)&lh->error, 0);
+
rn = getrn(lh, data, &hash);
if (*rn == NULL) {
- lh->num_retrieve_miss++;
+ tsan_counter(&lh->num_retrieve_miss);
return NULL;
} else {
ret = (*rn)->data;
- lh->num_retrieve++;
+ tsan_counter(&lh->num_retrieve);
}
+
return ret;
}
@@ -296,7 +298,7 @@ static OPENSSL_LH_NODE **getrn(OPENSSL_LHASH *lh,
OPENSSL_LH_COMPFUNC cf;
hash = (*(lh->hash)) (data);
- lh->num_hash_calls++;
+ tsan_counter(&lh->num_hash_calls);
*rhash = hash;
nn = hash % lh->pmax;
@@ -306,12 +308,12 @@ static OPENSSL_LH_NODE **getrn(OPENSSL_LHASH *lh,
cf = lh->comp;
ret = &(lh->b[(int)nn]);
for (n1 = *ret; n1 != NULL; n1 = n1->next) {
- lh->num_hash_comps++;
+ tsan_counter(&lh->num_hash_comps);
if (n1->hash != hash) {
ret = &(n1->next);
continue;
}
- lh->num_comp_calls++;
+ tsan_counter(&lh->num_comp_calls);
if (cf(n1->data, data) == 0)
break;
ret = &(n1->next);