rcuja: create shadow node for root
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sun, 19 Aug 2012 13:28:53 +0000 (09:28 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 14 May 2013 14:21:29 +0000 (16:21 +0200)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
rcuja/rcuja-internal.h
rcuja/rcuja.c

index 28908e050b06e88d4dc9003487ee4f912596b819..027780833845917502cbcd4e217e269d9d4a21dc 100644 (file)
@@ -43,6 +43,7 @@ struct cds_ja_shadow_node {
        pthread_mutex_t *lock;
        unsigned int nr_child;          /* number of children in node */
        struct rcu_head head;           /* for deferred node and shadow node reclaim */
+       int is_root;                    /* is it a root node ? */
 };
 
 struct cds_ja {
index 1c1d6e4677849f7b96bfb0ac644c3e535e8f78de..945b299ea397b1a25ae9c0c0a5b2cf9de78ee598 100644 (file)
@@ -876,7 +876,8 @@ int cds_ja_add(struct cds_ja *ja, uint64_t key,
 retry:
        iter_key = key;
        parent2_node_flag = NULL;
-       parent_node_flag = NULL;
+       parent_node_flag =
+               (struct cds_ja_inode_flag *) &ja->root; /* Use root ptr address as key for mutex */
        node_flag_ptr = &ja->root;
        node_flag = rcu_dereference(*node_flag_ptr);
 
@@ -921,6 +922,7 @@ struct cds_ja *_cds_ja_new(unsigned int key_bits,
                const struct rcu_flavor_struct *flavor)
 {
        struct cds_ja *ja;
+       int ret;
 
        ja = calloc(sizeof(*ja), 1);
        if (!ja)
@@ -950,8 +952,21 @@ struct cds_ja *_cds_ja_new(unsigned int key_bits,
        ja->ht = rcuja_create_ht(flavor);
        if (!ja->ht)
                goto ht_error;
+
+       /*
+        * Note: we should not free this node until judy array destroy.
+        */
+       ret = rcuja_shadow_set(ja->ht,
+                       ja_node_ptr((struct cds_ja_inode_flag *) &ja->root),
+                       NULL);
+       if (ret)
+               goto ht_node_error;
+
        return ja;
 
+ht_node_error:
+       ret = rcuja_delete_ht(ja->ht);
+       assert(!ret);
 ht_error:
 check_error:
        free(ja);
This page took 0.026488 seconds and 4 git commands to generate.