]> git.lttng.org Git - urcu.git/commitdiff
rculfhash: fall back to single-threaded resize on calloc failure
authorEric Wong <normalperson@yhbt.net>
Tue, 24 Jun 2014 01:20:30 +0000 (01:20 +0000)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 31 Jul 2014 20:43:07 +0000 (16:43 -0400)
Having a calloc fail on my server should not be fatal.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
rculfhash.c

index 7d39388f494700a1b06a5df885d5a5350cdf42a8..2a450459f5cfa50e94bce03e00be0ad1be7b2b4f 100644 (file)
@@ -1189,7 +1189,10 @@ void partition_resize_helper(struct cds_lfht *ht, unsigned long i,
        }
        partition_len = len >> cds_lfht_get_count_order_ulong(nr_threads);
        work = calloc(nr_threads, sizeof(*work));
-       assert(work);
+       if (!work) {
+               dbg_printf("error allocating for resize, single-threading\n");
+               goto fallback;
+       }
        for (thread = 0; thread < nr_threads; thread++) {
                work[thread].ht = ht;
                work[thread].i = i;
@@ -1205,6 +1208,11 @@ void partition_resize_helper(struct cds_lfht *ht, unsigned long i,
                assert(!ret);
        }
        free(work);
+       return;
+fallback:
+       ht->flavor->thread_online();
+       fct(ht, i, 0, len);
+       ht->flavor->thread_offline();
 }
 
 /*
This page took 0.030797 seconds and 4 git commands to generate.