}
level++;
+
+ /*
+ * From this point, we are guaranteed to be able to find a
+ * "lower than" match. ja_detach_node() guarantees that it is
+ * not possible for a lookup to reach a dead-end.
+ */
+
/* Find rightmost child of rightmost child (recursively). */
for (; level < tree_depth; level++) {
node_flag = ja_node_get_rightmost(node_flag);
break;
}
- if (level == tree_depth) {
- /* Last level lookup succeded. We got a "lower than" match. */
- head.next = (struct cds_hlist_node *) node_flag;
- return head;
- }
+ assert(level == tree_depth);
- /* No match */
+ head.next = (struct cds_hlist_node *) node_flag;
return head;
}
* However, when a child is removed from "linear" nodes, its pointer
* is set to NULL. We therefore check, while holding the locks, if this
* pointer is NULL, and return -ENOENT to the caller if it is the case.
+ *
+ * ja_detach_node() ensures that a lookup will _never_ see a branch that
+ * leads to a dead-end: when removing branch, it makes sure to perform
+ * the "cut" at the highest node that has only one child, effectively
+ * replacing it with a NULL pointer.
*/
static
int ja_detach_node(struct cds_ja *ja,