#include "eng_int.h"
#include <openssl/rand.h>
+#include "internal/refcount.h"
CRYPTO_RWLOCK *global_engine_lock;
DEFINE_RUN_ONCE(do_engine_lock_init)
{
+ OPENSSL_init_crypto(0, NULL);
global_engine_lock = CRYPTO_THREAD_lock_new();
return global_engine_lock != NULL;
}
e->flags = 0;
}
-int engine_free_util(ENGINE *e, int locked)
+int engine_free_util(ENGINE *e, int not_locked)
{
int i;
if (e == NULL)
return 1;
- if (locked)
+#ifdef HAVE_ATOMICS
+ CRYPTO_DOWN_REF(&e->struct_ref, &i, global_engine_lock);
+#else
+ if (not_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;