rcuja test: add specific free_node()
[urcu.git] / tests / test_urcu_ja.c
index ecbaf031e502c7592f497d49f7e7474f9d85b669..859dc166e48f55d1425204f6696b26cc5ae9d52e 100644 (file)
@@ -145,15 +145,21 @@ struct ja_test_node *node_alloc(void)
 }
 
 static
-void free_node_cb(struct rcu_head *head)
+void free_node(struct ja_test_node *node)
 {
-       struct ja_test_node *node =
-               caa_container_of(head, struct ja_test_node, node.head);
        poison_free(node);
        if (leak_detection)
                uatomic_inc(&test_nodes_freed);
 }
 
+static
+void free_node_cb(struct rcu_head *head)
+{
+       struct ja_test_node *node =
+               caa_container_of(head, struct ja_test_node, node.head);
+       free_node(node);
+}
+
 #if 0
 static
 void test_delete_all_nodes(struct cds_lfht *ht)
@@ -695,7 +701,7 @@ void *test_ja_rw_thr_writer(void *_count)
                        if (add_unique) {
                                ret_node = cds_ja_add_unique(test_ja, key, &node->node);
                                if (ret_node != &node->node) {
-                                       free(node);
+                                       free_node(node);
                                        URCU_TLS(nr_addexist)++;
                                } else {
                                        URCU_TLS(nr_add)++;
@@ -706,7 +712,7 @@ void *test_ja_rw_thr_writer(void *_count)
                                ret = cds_ja_add(test_ja, key, &node->node);
                                if (ret) {
                                        fprintf(stderr, "Error in cds_ja_add: %d\n", ret);
-                                       free(node);
+                                       free_node(node);
                                } else {
                                        URCU_TLS(nr_add)++;
                                }
@@ -1077,69 +1083,4 @@ int main(int argc, char **argv)
                printf("Test ended with error: %d\n", ret);
        }
        return ret;
-
-#if 0
-       /*
-        * Hash Population needs to be seen as a RCU reader
-        * thread from the point of view of resize.
-        */
-       rcu_register_thread();
-       ret = (get_populate_hash_cb())();
-       assert(!ret);
-
-       rcu_thread_offline();
-
-       /* teardown counter thread */
-       act.sa_handler = SIG_IGN;
-       act.sa_flags = SA_RESTART;
-       ret = sigaction(SIGUSR2, &act, NULL);
-       if (ret == -1) {
-               perror("sigaction");
-               return -1;
-       }
-       {
-               char msg[1] = { 0x42 };
-               ssize_t ret;
-
-               do {
-                       ret = write(count_pipe[1], msg, 1);     /* wakeup thread */
-               } while (ret == -1L && errno == EINTR);
-       }
-
-       fflush(stdout);
-       rcu_thread_online();
-       rcu_read_lock();
-       printf("Counting nodes... ");
-       cds_lfht_count_nodes(test_ht, &approx_before, &count, &approx_after);
-       printf("done.\n");
-       test_delete_all_nodes(test_ht);
-       rcu_read_unlock();
-       rcu_thread_offline();
-       if (count) {
-               printf("Approximation before node accounting: %ld nodes.\n",
-                       approx_before);
-               printf("Nodes deleted from hash table before destroy: "
-                       "%lu nodes.\n",
-                       count);
-               printf("Approximation after node accounting: %ld nodes.\n",
-                       approx_after);
-       }
-       ret = cds_lfht_destroy(test_ht, NULL);
-       if (ret)
-               printf_verbose("final delete aborted\n");
-       else
-               printf_verbose("final delete success\n");
-       printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads,
-              tot_writes);
-       printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu "
-               "nr_writers %3u "
-               "wdelay %6lu nr_reads %12llu nr_writes %12llu nr_ops %12llu "
-               "nr_add %12llu nr_add_fail %12llu nr_remove %12llu nr_leaked %12lld\n",
-               argv[0], duration, nr_readers, rduration,
-               nr_writers, wdelay, tot_reads, tot_writes,
-               tot_reads + tot_writes, tot_add, tot_add_exist, tot_remove,
-               (long long) tot_add + init_populate - tot_remove - count);
-       rcu_unregister_thread();
-#endif
-       return 0;
 }
This page took 0.023723 seconds and 4 git commands to generate.