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/engine/eng_lib.c | |
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/engine/eng_lib.c')
-rw-r--r-- | crypto/engine/eng_lib.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/crypto/engine/eng_lib.c b/crypto/engine/eng_lib.c index 28de21d73d..8a21f38028 100644 --- a/crypto/engine/eng_lib.c +++ b/crypto/engine/eng_lib.c @@ -9,6 +9,7 @@ #include "eng_int.h" #include <openssl/rand.h> +#include "internal/refcount.h" CRYPTO_RWLOCK *global_engine_lock; @@ -72,10 +73,14 @@ int engine_free_util(ENGINE *e, int locked) if (e == NULL) return 1; +#ifdef HAVE_ATOMICS + CRYPTO_DOWN_REF(&e->struct_ref, &i, global_engine_lock); +#else if (locked) CRYPTO_atomic_add(&e->struct_ref, -1, &i, global_engine_lock); else i = --e->struct_ref; +#endif engine_ref_debug(e, 0, -1) if (i > 0) return 1; |