From: Mathieu Desnoyers Date: Fri, 31 May 2013 16:31:38 +0000 (-0400) Subject: rcuja: return errors on destroy X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=19a748d9348a4982f983a6c267c0ac9b4b93636e;p=urcu.git rcuja: return errors on destroy Signed-off-by: Mathieu Desnoyers --- diff --git a/rcuja/rcuja.c b/rcuja/rcuja.c index 9f135b0..41ac70c 100644 --- a/rcuja/rcuja.c +++ b/rcuja/rcuja.c @@ -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; }