Killing the init_context in last position.
Adding debug.
Calling cleanup_func before freeing args.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3239
48e7efb5-ca39-0410-a469-
dd3cf9ba447f
void_f_pvoid_t startup_func, void *startup_arg,
void_f_pvoid_t cleanup_func, void *cleanup_arg,
int argc, char *argv[]);
void_f_pvoid_t startup_func, void *startup_arg,
void_f_pvoid_t cleanup_func, void *cleanup_arg,
int argc, char *argv[]);
-void xbt_context_free(xbt_context_t context);
+void xbt_context_kill(xbt_context_t context);
XBT_PUBLIC(void) xbt_context_start(xbt_context_t context);
XBT_PUBLIC(void) xbt_context_yield(void);
XBT_PUBLIC(void) xbt_context_schedule(xbt_context_t context);
XBT_PUBLIC(void) xbt_context_start(xbt_context_t context);
XBT_PUBLIC(void) xbt_context_yield(void);
XBT_PUBLIC(void) xbt_context_schedule(xbt_context_t context);
-static void xbt_context_destroy(xbt_context_t context)
+static void xbt_context_free(xbt_context_t context)
+ DEBUG1("Freeing %p",context);
#ifdef CONTEXT_THREADS
xbt_free(context->thread);
xbt_mutex_destroy(context->mutex);
#ifdef CONTEXT_THREADS
xbt_free(context->thread);
xbt_mutex_destroy(context->mutex);
{
if(!current_context){
current_context = init_context = xbt_new0(s_xbt_context_t,1);
{
if(!current_context){
current_context = init_context = xbt_new0(s_xbt_context_t,1);
+ DEBUG1("Init Context (%p)",init_context);
+
init_context->exception = xbt_new(ex_ctx_t,1);
XBT_CTX_INITIALIZE(init_context->exception);
__xbt_ex_ctx = __context_ex_ctx;
init_context->exception = xbt_new(ex_ctx_t,1);
XBT_CTX_INITIALIZE(init_context->exception);
__xbt_ex_ctx = __context_ex_ctx;
void xbt_context_empty_trash(void)
{
xbt_context_t context=NULL;
void xbt_context_empty_trash(void)
{
xbt_context_t context=NULL;
+ DEBUG0("Emptying trashbin");
while((context=xbt_swag_extract(context_to_destroy)))
while((context=xbt_swag_extract(context_to_destroy)))
- xbt_context_destroy(context);
+ xbt_context_free(context);
xbt_swag_free(context_to_destroy);
while((context=xbt_swag_extract(context_living))) {
xbt_swag_free(context_to_destroy);
while((context=xbt_swag_extract(context_living))) {
- xbt_context_free(context);
+ if(context!=init_context) xbt_context_kill(context);
+ xbt_context_kill(init_context);
xbt_swag_free(context_living);
init_context = current_context = NULL ;
xbt_swag_free(context_living);
init_context = current_context = NULL ;
*
* This function simply kills \a context... scarry isn't it ?
*/
*
* This function simply kills \a context... scarry isn't it ?
*/
-void xbt_context_free(xbt_context_t context)
+void xbt_context_kill(xbt_context_t context)
+ DEBUG1("Killing %p", context);
xbt_swag_remove(context, context_living);
xbt_swag_remove(context, context_living);
+ if(context->cleanup_func) {
+ DEBUG1("Calling cleanup function %p", context->cleanup_func);
+ context->cleanup_func(context->cleanup_arg);
+ }
+
+ DEBUG0("Freeing arguments");
for(i=0;i<context->argc; i++)
if(context->argv[i])
free(context->argv[i]);
for(i=0;i<context->argc; i++)
if(context->argv[i])
free(context->argv[i]);
if(context->argv)
free(context->argv);
if(context->argv)
free(context->argv);
- if(context->cleanup_func)
- context->cleanup_func(context->cleanup_arg);
-
- xbt_context_destroy(context);
+ xbt_context_free(context);