diff options
author | Pauli <pauli@openssl.org> | 2023-06-22 01:41:30 +0200 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2023-07-01 13:18:25 +0200 |
commit | 7d6ab1210603c23a4f2cbfb5c542726afe3b08cc (patch) | |
tree | f4f6f091dbc126f6d9954795e83a7495ebd38e1b /crypto/encode_decode | |
parent | quic: update to structure based atomics (diff) | |
download | openssl-7d6ab1210603c23a4f2cbfb5c542726afe3b08cc.tar.xz openssl-7d6ab1210603c23a4f2cbfb5c542726afe3b08cc.zip |
encoder: update to structure based atomics
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21260)
Diffstat (limited to 'crypto/encode_decode')
-rw-r--r-- | crypto/encode_decode/decoder_meth.c | 11 | ||||
-rw-r--r-- | crypto/encode_decode/encoder_local.h | 1 | ||||
-rw-r--r-- | crypto/encode_decode/encoder_meth.c | 11 |
3 files changed, 8 insertions, 15 deletions
diff --git a/crypto/encode_decode/decoder_meth.c b/crypto/encode_decode/decoder_meth.c index b133402e09..fca8be1bb1 100644 --- a/crypto/encode_decode/decoder_meth.c +++ b/crypto/encode_decode/decoder_meth.c @@ -31,14 +31,11 @@ static OSSL_DECODER *ossl_decoder_new(void) if ((decoder = OPENSSL_zalloc(sizeof(*decoder))) == NULL) return NULL; - if ((decoder->base.lock = CRYPTO_THREAD_lock_new()) == NULL) { + if (!CRYPTO_NEW_REF(&decoder->base.refcnt, 1)) { OSSL_DECODER_free(decoder); - ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_CRYPTO_LIB); return NULL; } - decoder->base.refcnt = 1; - return decoder; } @@ -46,7 +43,7 @@ int OSSL_DECODER_up_ref(OSSL_DECODER *decoder) { int ref = 0; - CRYPTO_UP_REF(&decoder->base.refcnt, &ref, decoder->base.lock); + CRYPTO_UP_REF(&decoder->base.refcnt, &ref); return 1; } @@ -57,13 +54,13 @@ void OSSL_DECODER_free(OSSL_DECODER *decoder) if (decoder == NULL) return; - CRYPTO_DOWN_REF(&decoder->base.refcnt, &ref, decoder->base.lock); + CRYPTO_DOWN_REF(&decoder->base.refcnt, &ref); if (ref > 0) return; OPENSSL_free(decoder->base.name); ossl_property_free(decoder->base.parsed_propdef); ossl_provider_free(decoder->base.prov); - CRYPTO_THREAD_lock_free(decoder->base.lock); + CRYPTO_FREE_REF(&decoder->base.refcnt); OPENSSL_free(decoder); } diff --git a/crypto/encode_decode/encoder_local.h b/crypto/encode_decode/encoder_local.h index 6a5bf16ae9..62da028bec 100644 --- a/crypto/encode_decode/encoder_local.h +++ b/crypto/encode_decode/encoder_local.h @@ -25,7 +25,6 @@ struct ossl_endecode_base_st { OSSL_PROPERTY_LIST *parsed_propdef; CRYPTO_REF_COUNT refcnt; - CRYPTO_RWLOCK *lock; }; struct ossl_encoder_st { diff --git a/crypto/encode_decode/encoder_meth.c b/crypto/encode_decode/encoder_meth.c index 9093f29abb..dbc8d9f997 100644 --- a/crypto/encode_decode/encoder_meth.c +++ b/crypto/encode_decode/encoder_meth.c @@ -31,14 +31,11 @@ static OSSL_ENCODER *ossl_encoder_new(void) if ((encoder = OPENSSL_zalloc(sizeof(*encoder))) == NULL) return NULL; - if ((encoder->base.lock = CRYPTO_THREAD_lock_new()) == NULL) { + if (!CRYPTO_NEW_REF(&encoder->base.refcnt, 1)) { OSSL_ENCODER_free(encoder); - ERR_raise(ERR_LIB_OSSL_ENCODER, ERR_R_CRYPTO_LIB); return NULL; } - encoder->base.refcnt = 1; - return encoder; } @@ -46,7 +43,7 @@ int OSSL_ENCODER_up_ref(OSSL_ENCODER *encoder) { int ref = 0; - CRYPTO_UP_REF(&encoder->base.refcnt, &ref, encoder->base.lock); + CRYPTO_UP_REF(&encoder->base.refcnt, &ref); return 1; } @@ -57,13 +54,13 @@ void OSSL_ENCODER_free(OSSL_ENCODER *encoder) if (encoder == NULL) return; - CRYPTO_DOWN_REF(&encoder->base.refcnt, &ref, encoder->base.lock); + CRYPTO_DOWN_REF(&encoder->base.refcnt, &ref); if (ref > 0) return; OPENSSL_free(encoder->base.name); ossl_property_free(encoder->base.parsed_propdef); ossl_provider_free(encoder->base.prov); - CRYPTO_THREAD_lock_free(encoder->base.lock); + CRYPTO_FREE_REF(&encoder->base.refcnt); OPENSSL_free(encoder); } |