X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/504b4d20dd2db9ea1eaa9c4b390b2a412d7c9779..abcec414741588aaaa8b719ae581b183b2327569:/src/xbt/xbt_sg_synchro.c diff --git a/src/xbt/xbt_sg_synchro.c b/src/xbt/xbt_sg_synchro.c index 306436d45c..6500d934a1 100644 --- a/src/xbt/xbt_sg_synchro.c +++ b/src/xbt/xbt_sg_synchro.c @@ -25,7 +25,7 @@ typedef struct s_xbt_thread_ { smx_process_t s_process; void_f_pvoid_t code; void *userparam; - void *father_data; + void *father_data; } s_xbt_thread_t; static int xbt_thread_create_wrapper(int argc, char *argv[]) { @@ -45,7 +45,7 @@ xbt_thread_t xbt_thread_create(const char*name,void_f_pvoid_t code, void* param) res->s_process = SIMIX_process_create(name, xbt_thread_create_wrapper, res, SIMIX_host_get_name(SIMIX_host_self()), - 0, NULL,/*props*/NULL); + 0,NULL,/*props*/NULL); // free(name); return res; } @@ -55,7 +55,8 @@ const char* xbt_thread_name(xbt_thread_t t) { } const char* xbt_thread_self_name(void) { - return xbt_thread_self()->name; + xbt_thread_t me = xbt_thread_self(); + return me ? me->name : "maestro"; } @@ -67,6 +68,7 @@ xbt_thread_join(xbt_thread_t thread) { void xbt_thread_cancel(xbt_thread_t thread) { SIMIX_process_kill(thread->s_process); + free(thread->name); free(thread); } @@ -77,7 +79,8 @@ void xbt_thread_exit() { } xbt_thread_t xbt_thread_self(void) { - return SIMIX_process_get_data(SIMIX_process_self()); + smx_process_t p = SIMIX_process_self(); + return p ? SIMIX_process_get_data(p) : NULL; } void xbt_thread_yield(void) {