Lines Matching refs:h

294 static int ossl_ht_flush_internal(HT *h)  in ossl_ht_flush_internal()  argument
313 oldmd = ossl_rcu_deref(&h->md); in ossl_ht_flush_internal()
314 ossl_rcu_assign_ptr(&h->md, &newmd); in ossl_ht_flush_internal()
317 h->wpd.value_count = 0; in ossl_ht_flush_internal()
318 h->wpd.neighborhood_len = DEFAULT_NEIGH_LEN; in ossl_ht_flush_internal()
320 ossl_rcu_call(h->lock, free_oldmd, oldmd); in ossl_ht_flush_internal()
321 h->wpd.need_sync = 1; in ossl_ht_flush_internal()
325 int ossl_ht_flush(HT *h) in ossl_ht_flush() argument
327 return ossl_ht_flush_internal(h); in ossl_ht_flush()
330 void ossl_ht_free(HT *h) in ossl_ht_free() argument
332 if (h == NULL) in ossl_ht_free()
335 ossl_ht_write_lock(h); in ossl_ht_free()
336 ossl_ht_flush_internal(h); in ossl_ht_free()
337 ossl_ht_write_unlock(h); in ossl_ht_free()
339 CRYPTO_THREAD_lock_free(h->atomic_lock); in ossl_ht_free()
340 ossl_rcu_lock_free(h->lock); in ossl_ht_free()
341 OPENSSL_free(h->md->neighborhood_ptr_to_free); in ossl_ht_free()
342 OPENSSL_free(h->md); in ossl_ht_free()
343 OPENSSL_free(h); in ossl_ht_free()
347 size_t ossl_ht_count(HT *h) in ossl_ht_count() argument
351 count = h->wpd.value_count; in ossl_ht_count()
355 void ossl_ht_foreach_until(HT *h, int (*cb)(HT_VALUE *obj, void *arg), in ossl_ht_foreach_until() argument
361 md = ossl_rcu_deref(&h->md); in ossl_ht_foreach_until()
375 HT_VALUE_LIST *ossl_ht_filter(HT *h, size_t max_len, in ossl_ht_filter() argument
394 md = ossl_rcu_deref(&h->md); in ossl_ht_filter()
432 static int grow_hashtable(HT *h, size_t oldsize) in grow_hashtable() argument
435 struct ht_mutable_data_st *oldmd = ossl_rcu_deref(&h->md); in grow_hashtable()
443 if (h->config.lockless_reads) in grow_hashtable()
463 for (oldi = 0; oldi < h->wpd.neighborhood_len; oldi++) { in grow_hashtable()
484 return grow_hashtable(h, newsize); in grow_hashtable()
492 h->wpd.neighborhood_len = newsize; in grow_hashtable()
497 ossl_rcu_assign_ptr(&h->md, &newmd); in grow_hashtable()
498 ossl_rcu_call(h->lock, free_old_neigh_table, oldmd); in grow_hashtable()
499 h->wpd.need_sync = 1; in grow_hashtable()
515 HT_VALUE *h = (HT_VALUE *)arg; in free_old_ht_value() local
523 OPENSSL_free(h); in free_old_ht_value()
540 static int ossl_ht_insert_locked(HT *h, uint64_t hash, in ossl_ht_insert_locked() argument
544 struct ht_mutable_data_st *md = h->md; in ossl_ht_insert_locked()
551 int lockless_reads = h->config.lockless_reads; in ossl_ht_insert_locked()
566 &ihash, h->atomic_lock)) in ossl_ht_insert_locked()
576 hash, h->atomic_lock)) in ossl_ht_insert_locked()
581 ossl_rcu_call(h->lock, free_old_ht_value, *olddata); in ossl_ht_insert_locked()
582 h->wpd.need_sync = 1; in ossl_ht_insert_locked()
597 hash, h->atomic_lock)) in ossl_ht_insert_locked()
599 h->wpd.value_count++; in ossl_ht_insert_locked()
605 static struct ht_internal_value_st *alloc_new_value(HT *h, HT_KEY *key, in alloc_new_value() argument
612 if (h->config.collision_check == 1) in alloc_new_value()
620 tmp->ht = h; in alloc_new_value()
624 if (h->config.collision_check) { in alloc_new_value()
639 int ossl_ht_insert(HT *h, HT_KEY *key, HT_VALUE *data, HT_VALUE **olddata) in ossl_ht_insert() argument
649 newval = alloc_new_value(h, key, data->value, data->type_id); in ossl_ht_insert()
657 hash = h->config.ht_hash_fn(key->keybuf, key->keysize); in ossl_ht_insert()
660 (rc = ossl_ht_insert_locked(h, hash, newval, olddata)) == -1 in ossl_ht_insert()
663 if (!grow_hashtable(h, h->wpd.neighborhood_len)) { in ossl_ht_insert()
675 HT_VALUE *ossl_ht_get(HT *h, HT_KEY *key) in ossl_ht_get() argument
684 int lockless_reads = h->config.lockless_reads; in ossl_ht_get()
686 hash = h->config.ht_hash_fn(key->keybuf, key->keysize); in ossl_ht_get()
688 md = ossl_rcu_deref(&h->md); in ossl_ht_get()
701 &ehash, h->atomic_lock)) in ossl_ht_get()
723 int ossl_ht_delete(HT *h, HT_KEY *key) in ossl_ht_delete() argument
732 if (h->config.lockless_reads) in ossl_ht_delete()
735 hash = h->config.ht_hash_fn(key->keybuf, key->keysize); in ossl_ht_delete()
737 neigh_idx = hash & h->md->neighborhood_mask; in ossl_ht_delete()
738 PREFETCH_NEIGHBORHOOD(h->md->neighborhoods[neigh_idx]); in ossl_ht_delete()
740 v = (struct ht_internal_value_st *)h->md->neighborhoods[neigh_idx].entries[j].value; in ossl_ht_delete()
743 if (compare_hash(hash, h->md->neighborhoods[neigh_idx].entries[j].hash) in ossl_ht_delete()
745 if (!CRYPTO_atomic_store(&h->md->neighborhoods[neigh_idx].entries[j].hash, in ossl_ht_delete()
746 0, h->atomic_lock)) in ossl_ht_delete()
748 h->wpd.value_count--; in ossl_ht_delete()
749 ossl_rcu_assign_ptr(&h->md->neighborhoods[neigh_idx].entries[j].value, in ossl_ht_delete()
756 ossl_rcu_call(h->lock, free_old_entry, v); in ossl_ht_delete()
757 h->wpd.need_sync = 1; in ossl_ht_delete()