[lttng-dev] [PATCH 1/3] rculfhash: fall back to single-threaded resize on calloc failure

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Thu Jul 31 16:45:14 EDT 2014


Merged into master, stable-0.7 and stable-0.8, thanks!

Mathieu

----- Original Message -----
> From: "Eric Wong" <normalperson at yhbt.net>
> To: lttng-dev at lists.lttng.org
> Cc: e at 80x24.org
> Sent: Monday, June 23, 2014 9:20:30 PM
> Subject: [lttng-dev] [PATCH 1/3] rculfhash: fall back to single-threaded	resize on calloc failure
> 
> Having a calloc fail on my server should not be fatal.
> 
> Signed-off-by: Eric Wong <normalperson at yhbt.net>
> ---
>  rculfhash.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/rculfhash.c b/rculfhash.c
> index 7d39388..2a45045 100644
> --- a/rculfhash.c
> +++ b/rculfhash.c
> @@ -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();
>  }
>  
>  /*
> --
> 2.0.0.259.gbf1bc9c
> 
> 
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
> 

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com



More information about the lttng-dev mailing list