rcuja: return errors on destroy
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 31 May 2013 16:31:38 +0000 (12:31 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 31 May 2013 16:31:38 +0000 (12:31 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
rcuja/rcuja.c

index 9f135b08ee5ebd5d8d70b32ae0277b0917957512..41ac70c43fb457aa98ae7ba80ebfce4b515904b6 100644 (file)
@@ -2415,10 +2415,11 @@ void print_debug_fallback_distribution(struct cds_ja *ja)
 }
 
 static
-void print_ja_debug_info(struct cds_ja *ja)
+int ja_final_checks(struct cds_ja *ja)
 {
        double fallback_ratio;
        unsigned long na, nf, nr_fallback;
+       int ret = 0;
 
        fallback_ratio = (double) uatomic_read(&ja->nr_fallback);
        fallback_ratio /= (double) uatomic_read(&ja->nr_nodes_allocated);
@@ -2431,13 +2432,16 @@ void print_ja_debug_info(struct cds_ja *ja)
 
        na = uatomic_read(&ja->nr_nodes_allocated);
        nf = uatomic_read(&ja->nr_nodes_freed);
+       dbg_printf("Nodes allocated: %lu, Nodes freed: %lu.\n", na, nf);
+       if (nr_fallback)
+               print_debug_fallback_distribution(ja);
+
        if (na != nf) {
                fprintf(stderr, "[error] Judy array leaked %ld nodes. Allocated: %lu, freed: %lu.\n",
                        (long) na - nf, na, nf);
+               ret = -1;
        }
-       dbg_printf("Nodes allocated: %lu, Nodes freed: %lu.\n", na, nf);
-       if (nr_fallback)
-               print_debug_fallback_distribution(ja);
+       return ret;
 }
 
 /*
@@ -2463,7 +2467,7 @@ int cds_ja_destroy(struct cds_ja *ja,
        flavor->barrier();
 
        flavor->thread_online();
-       print_ja_debug_info(ja);
+       ret = ja_final_checks(ja);
        free(ja);
-       return 0;
+       return ret;
 }
This page took 0.026602 seconds and 4 git commands to generate.