diff options
author | Alessandro Ghedini <alessandro@ghedini.me> | 2016-03-01 18:06:15 +0000 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2016-03-08 11:10:34 -0500 |
commit | c001ce33137993a0c4ff15060ed1639826bfca0b (patch) | |
tree | 0589954d36d7138b51b4e9906a2d728e9c25669c /crypto/asn1/tasn_utl.c | |
parent | 41cfbccc99f3ca3c9f656d8c71e2db5bcfcf6817 (diff) |
Convert CRYPTO_LOCK_X509_* to new multi-threading API
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'crypto/asn1/tasn_utl.c')
-rw-r--r-- | crypto/asn1/tasn_utl.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/crypto/asn1/tasn_utl.c b/crypto/asn1/tasn_utl.c index c840047cdf..41f2fc24a0 100644 --- a/crypto/asn1/tasn_utl.c +++ b/crypto/asn1/tasn_utl.c @@ -105,6 +105,7 @@ int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it) { const ASN1_AUX *aux; int *lck, ret; + CRYPTO_RWLOCK **lock; if ((it->itype != ASN1_ITYPE_SEQUENCE) && (it->itype != ASN1_ITYPE_NDEF_SEQUENCE)) return 0; @@ -112,15 +113,21 @@ int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it) if (!aux || !(aux->flags & ASN1_AFLG_REFCOUNT)) return 0; lck = offset2ptr(*pval, aux->ref_offset); + lock = offset2ptr(*pval, aux->ref_lock); if (op == 0) { *lck = 1; + *lock = CRYPTO_THREAD_lock_new(); + if (*lock == NULL) + return 0; return 1; } - ret = CRYPTO_add(lck, op, aux->ref_lock); + CRYPTO_atomic_add(lck, op, &ret, *lock); #ifdef REF_PRINT fprintf(stderr, "%p:%4d:%s\n", it, *lck, it->sname); #endif REF_ASSERT_ISNT(ret < 0); + if (ret == 0) + CRYPTO_THREAD_lock_free(*lock); return ret; } |