+ iter_prev = rcu_dereference(t->tbl[hash & (t->size - 1)]);
+ /* We can always skip the dummy node initially */
+ iter = rcu_dereference(iter_prev->p.next);
+ assert(iter_prev->p.reverse_hash <= node->p.reverse_hash);
+ for (;;) {
+ if (unlikely(!clear_flag(iter)))
+ goto insert;
+ if (clear_flag(iter)->p.reverse_hash > node->p.reverse_hash)
+ goto insert;
+ next = rcu_dereference(clear_flag(iter)->p.next);
+ if (is_removed(next))
+ goto gc_node;
+ if (unique
+ && !is_dummy(next)
+ && !ht->compare_fct(node->key, node->key_len,
+ clear_flag(iter)->key,
+ clear_flag(iter)->key_len))
+ return clear_flag(iter);
+ /* Only account for identical reverse hash once */
+ if (iter_prev->p.reverse_hash != clear_flag(iter)->p.reverse_hash)
+ check_resize(ht, t, ++chain_len);
+ iter_prev = clear_flag(iter);
+ iter = next;
+ }
+ insert:
+ assert(node != clear_flag(iter));
+ assert(!is_removed(iter_prev));
+ assert(iter_prev != node);
+ if (!dummy)
+ node->p.next = clear_flag(iter);
+ else
+ node->p.next = flag_dummy(clear_flag(iter));
+ if (is_dummy(iter))
+ new_node = flag_dummy(node);
+ else
+ new_node = node;
+ if (uatomic_cmpxchg(&iter_prev->p.next, iter,
+ new_node) != iter)
+ continue; /* retry */
+ else
+ goto gc_end;
+ gc_node:
+ assert(!is_removed(iter));
+ if (is_dummy(iter))
+ new_next = flag_dummy(clear_flag(next));
+ else
+ new_next = clear_flag(next);
+ (void) uatomic_cmpxchg(&iter_prev->p.next, iter, new_next);
+ /* retry */