diff options
author | Kurt Roeckx <kurt@roeckx.be> | 2016-08-27 16:01:08 +0200 |
---|---|---|
committer | Kurt Roeckx <kurt@roeckx.be> | 2016-11-17 22:02:25 +0100 |
commit | 2f545ae45d4b93649e40ff7f93e2c3e6ce3154ae (patch) | |
tree | f29ebce27f6c271c3e7f99a3f96df6c4aadd5404 /crypto/x509 | |
parent | b6c6898234a12b9c6cdaa8f16fb9156097649ad7 (diff) |
Add support for reference counting using C11 atomics
Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
GH: #1500
Diffstat (limited to 'crypto/x509')
-rw-r--r-- | crypto/x509/x509_lcl.h | 4 | ||||
-rw-r--r-- | crypto/x509/x509_lu.c | 4 | ||||
-rw-r--r-- | crypto/x509/x509_set.c | 2 | ||||
-rw-r--r-- | crypto/x509/x509cset.c | 2 |
4 files changed, 7 insertions, 5 deletions
diff --git a/crypto/x509/x509_lcl.h b/crypto/x509/x509_lcl.h index 9b22974f4d..0cc38c6443 100644 --- a/crypto/x509/x509_lcl.h +++ b/crypto/x509/x509_lcl.h @@ -7,6 +7,8 @@ * https://www.openssl.org/source/license.html */ +#include "internal/refcount.h" + /* * This structure holds all parameters associated with a verify operation by * including an X509_VERIFY_PARAM structure in related structures the @@ -130,7 +132,7 @@ struct x509_store_st { STACK_OF(X509_CRL) *(*lookup_crls) (X509_STORE_CTX *ctx, X509_NAME *nm); int (*cleanup) (X509_STORE_CTX *ctx); CRYPTO_EX_DATA ex_data; - int references; + CRYPTO_REF_COUNT references; CRYPTO_RWLOCK *lock; }; diff --git a/crypto/x509/x509_lu.c b/crypto/x509/x509_lu.c index 04ae1cbb30..d425a057ca 100644 --- a/crypto/x509/x509_lu.c +++ b/crypto/x509/x509_lu.c @@ -196,7 +196,7 @@ void X509_STORE_free(X509_STORE *vfy) if (vfy == NULL) return; - CRYPTO_atomic_add(&vfy->references, -1, &i, vfy->lock); + CRYPTO_DOWN_REF(&vfy->references, &i, vfy->lock); REF_PRINT_COUNT("X509_STORE", vfy); if (i > 0) return; @@ -221,7 +221,7 @@ int X509_STORE_up_ref(X509_STORE *vfy) { int i; - if (CRYPTO_atomic_add(&vfy->references, 1, &i, vfy->lock) <= 0) + if (CRYPTO_UP_REF(&vfy->references, &i, vfy->lock) <= 0) return 0; REF_PRINT_COUNT("X509_STORE", a); diff --git a/crypto/x509/x509_set.c b/crypto/x509/x509_set.c index c0ea41883d..e46174a463 100644 --- a/crypto/x509/x509_set.c +++ b/crypto/x509/x509_set.c @@ -96,7 +96,7 @@ int X509_up_ref(X509 *x) { int i; - if (CRYPTO_atomic_add(&x->references, 1, &i, x->lock) <= 0) + if (CRYPTO_UP_REF(&x->references, &i, x->lock) <= 0) return 0; REF_PRINT_COUNT("X509", x); diff --git a/crypto/x509/x509cset.c b/crypto/x509/x509cset.c index 205785961b..3c9c32296e 100644 --- a/crypto/x509/x509cset.c +++ b/crypto/x509/x509cset.c @@ -67,7 +67,7 @@ int X509_CRL_up_ref(X509_CRL *crl) { int i; - if (CRYPTO_atomic_add(&crl->references, 1, &i, crl->lock) <= 0) + if (CRYPTO_UP_REF(&crl->references, &i, crl->lock) <= 0) return 0; REF_PRINT_COUNT("X509_CRL", crl); |