Add missing read lock in test, cleanup transplant
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sun, 29 May 2011 00:46:13 +0000 (20:46 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sun, 29 May 2011 00:46:13 +0000 (20:46 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
tests/test_urcu_rbtree.c
urcu-rbtree.c

index 9c597266d9f6b5602e9d943066388b26fc9ff3c5..587db7bd3c7ba4477e8298138bec12c81a7ba89f 100644 (file)
@@ -462,6 +462,8 @@ int main(int argc, char **argv)
                        exit(1);
        }
 
+       rcu_register_thread();
+       rcu_read_lock();
        /* Insert items looked up by readers */
        for (i = 0; i < global_items; i++) {
                node = rbtree_alloc();
@@ -469,6 +471,7 @@ int main(int argc, char **argv)
                node->key = global_key[i];
                rcu_rbtree_insert(&rbtree, node);
        }
+       rcu_read_unlock();
 
        cmm_smp_mb();
 
@@ -491,12 +494,15 @@ int main(int argc, char **argv)
                tot_writes += count_writer[i];
        }
        
+       rcu_read_lock();
        for (i = 0; i < global_items; i++) {
                node = rcu_rbtree_search(&rbtree, rbtree.root, global_key[i]);
                assert(!rcu_rbtree_is_nil(node));
                rcu_rbtree_remove(&rbtree, node);
                call_rcu(&node->head, rbtree_free);
        }
+       rcu_read_unlock();
+       rcu_unregister_thread();
 
        printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads,
               tot_writes);
index d612045ce817c38dcd0c61ca4077fe834b31d612..7e1b3330888af28cc0789422799a5fb2db849aa7 100644 (file)
@@ -576,17 +576,16 @@ void rcu_rbtree_transplant(struct rcu_rbtree *rbtree,
                v->p = u->p;
                cmm_smp_wmb();  /* write into node before publish */
                _CMM_STORE_SHARED(rbtree->root, v);
-       } else if (u == u->p->left) {
-               v->pos = IS_LEFT;
-               v->p = u->p;
-               cmm_smp_wmb();  /* write into node before publish */
-               _CMM_STORE_SHARED(u->p->left, v);
        } else {
-               v->pos = IS_RIGHT;
+               v->pos = u->pos;
                v->p = u->p;
                cmm_smp_wmb();  /* write into node before publish */
-               _CMM_STORE_SHARED(u->p->right, v);
+               if (u->pos == IS_LEFT)
+                       _CMM_STORE_SHARED(u->p->left, v);
+               else
+                       _CMM_STORE_SHARED(u->p->right, v);
        }
+
        /* Point children to new copy (parent only used by updates/next/prev) */
        if (!rcu_rbtree_is_nil(v)) {
                v->right->p = get_decay(v->right->p);
This page took 0.033079 seconds and 4 git commands to generate.