From a552921171e596c500551c63e8fc6d00c8b2dcd5 Mon Sep 17 00:00:00 2001 From: Dave Goodell Date: Thu, 29 Aug 2013 22:56:31 +0000 Subject: [PATCH] call element destructors in ompi_free_list_destruct The free list code called the constructor for each object it slab allocated in ompi_free_list_grow. This permits free list-managed elements to safely allocate/deallocate resources in their constructors/destructors without leaking. It's probably best to let this soak on the trunk a little while before moving it over to v1.7. Reviewed-by: bosilca cmr=v1.7.4:reviewer=bosilca This commit was SVN r29096. --- ompi/class/ompi_free_list.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ompi/class/ompi_free_list.c b/ompi/class/ompi_free_list.c index dfec72463a..a1b2eb58bb 100644 --- a/ompi/class/ompi_free_list.c +++ b/ompi/class/ompi_free_list.c @@ -11,7 +11,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2006-2007 Mellanox Technologies. All rights reserved. - * Copyright (c) 2010 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2010-2013 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2011 NVIDIA Corporation. All rights reserved. * Copyright (c) 2012 Los Alamos National Security, LLC. All rights * reserved. @@ -62,6 +62,7 @@ static void ompi_free_list_construct(ompi_free_list_t* fl) static void ompi_free_list_destruct(ompi_free_list_t* fl) { opal_list_item_t *item; + ompi_free_list_item_t *fl_item; ompi_free_list_memory_t *fl_mem; #if 0 && OPAL_ENABLE_DEBUG @@ -72,6 +73,15 @@ static void ompi_free_list_destruct(ompi_free_list_t* fl) } #endif + while(NULL != (item = opal_atomic_lifo_pop(&(fl->super)))) { + fl_item = (ompi_free_list_item_t*)item; + + /* destruct the item (we constructed it), the underlying memory will be + * reclaimed when we free the slab (ompi_free_list_memory_t ptr) + * containing it */ + OBJ_DESTRUCT(fl_item); + } + while(NULL != (item = opal_list_remove_first(&(fl->fl_allocations)))) { fl_mem = (ompi_free_list_memory_t*)item;