X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=rculfhash.c;h=c1ff314bc0d5cc748e1329d8508f72641ae804ad;hb=feda272217fca3604e904b83845814223b877287;hp=75e5ece96c9edb3e462b861fe61e682561d7a1c4;hpb=bc8c3c74b84e838b195faa8871344f5b672ae1cd;p=urcu.git diff --git a/rculfhash.c b/rculfhash.c index 75e5ece..c1ff314 100644 --- a/rculfhash.c +++ b/rculfhash.c @@ -779,9 +779,9 @@ int _cds_lfht_replace(struct cds_lfht *ht, unsigned long size, */ return -ENOENT; } - assert(!is_bucket(old_next)); - assert(new_node != clear_flag(old_next)); - new_node->next = clear_flag(old_next); + assert(old_next == clear_flag(old_next)); + assert(new_node != old_next); + new_node->next = old_next; /* * Here is the whole trick for lock-free replace: we add * the replacement node _after_ the node we want to @@ -1517,11 +1517,22 @@ struct cds_lfht_node *cds_lfht_add_replace(struct cds_lfht *ht, } } -int cds_lfht_replace(struct cds_lfht *ht, struct cds_lfht_iter *old_iter, +int cds_lfht_replace(struct cds_lfht *ht, + struct cds_lfht_iter *old_iter, + unsigned long hash, + cds_lfht_match_fct match, + const void *key, struct cds_lfht_node *new_node) { unsigned long size; + new_node->reverse_hash = bit_reverse_ulong((unsigned long) hash); + if (!old_iter->node) + return -ENOENT; + if (caa_unlikely(old_iter->node->reverse_hash != new_node->reverse_hash)) + return -EINVAL; + if (caa_unlikely(!match(old_iter->node, key))) + return -EINVAL; size = rcu_dereference(ht->size); return _cds_lfht_replace(ht, size, old_iter->node, old_iter->next, new_node);