- CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
-
- return p;
-}
-
-static unsigned long err_state_hash(const ERR_STATE *a)
-{
- return CRYPTO_THREADID_hash(&a->tid) * 13;
-}
-
-static IMPLEMENT_LHASH_HASH_FN(err_state, ERR_STATE)
-
-static int err_state_cmp(const ERR_STATE *a, const ERR_STATE *b)
-{
- return CRYPTO_THREADID_cmp(&a->tid, &b->tid);
-}
-
-static IMPLEMENT_LHASH_COMP_FN(err_state, ERR_STATE)
-
-static LHASH_OF(ERR_STATE) *int_thread_get(int create, int lockit)
-{
- LHASH_OF(ERR_STATE) *ret = NULL;
-
- if (lockit)
- CRYPTO_w_lock(CRYPTO_LOCK_ERR);
- if (!int_thread_hash && create) {
- CRYPTO_push_info("int_thread_get (err.c)");
- int_thread_hash = lh_ERR_STATE_new();
- CRYPTO_pop_info();
- }
- if (int_thread_hash != NULL) {
- int_thread_hash_references++;
- ret = int_thread_hash;
- }
- if (lockit)
- CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
- return ret;
-}
-
-static void int_thread_release(LHASH_OF(ERR_STATE) **hash)
-{
- int i;
-
- if (hash == NULL || *hash == NULL)
- return;
-
- i = CRYPTO_add(&int_thread_hash_references, -1, CRYPTO_LOCK_ERR);
-
-#ifdef REF_PRINT
- fprintf(stderr, "%4d:%s\n", int_thread_hash_references, "ERR");
-#endif
- if (i > 0)
- return;
-#ifdef REF_CHECK
- if (i < 0) {
- fprintf(stderr, "int_thread_release, bad reference count\n");
- abort(); /* ok */
- }
-#endif
- *hash = NULL;
-}
-
-static ERR_STATE *int_thread_get_item(const ERR_STATE *d)
-{
- ERR_STATE *p = NULL;
- LHASH_OF(ERR_STATE) *hash;
-
- CRYPTO_r_lock(CRYPTO_LOCK_ERR);
- hash = int_thread_get(0, 0);
- if (hash)
- p = lh_ERR_STATE_retrieve(hash, d);
- CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
-
- int_thread_release(&hash);
- return p;
-}
-
-static ERR_STATE *int_thread_set_item(ERR_STATE *d)
-{
- ERR_STATE *p = NULL;
- LHASH_OF(ERR_STATE) *hash;
-
- CRYPTO_w_lock(CRYPTO_LOCK_ERR);
- hash = int_thread_get(1, 0);
- if (hash)
- p = lh_ERR_STATE_insert(hash, d);
- CRYPTO_w_unlock(CRYPTO_LOCK_ERR);