Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Bugfix: Protect SIMIX_process_self in the case that the context module is not yet...
[simgrid.git] / src / simix / smx_process.c
index 1c06a6c..f22b2cc 100644 (file)
@@ -25,10 +25,9 @@ static unsigned long simix_process_count = 0;
  */
 XBT_INLINE smx_process_t SIMIX_process_self(void)
 {
-  if (simix_global)
-    return SIMIX_context_get_data(SIMIX_context_self());
+  smx_context_t self_context = SIMIX_context_self();
 
-  return NULL;
+  return self_context ? SIMIX_context_get_data(self_context) : NULL;
 }
 
 /**
@@ -153,7 +152,6 @@ smx_process_t SIMIX_process_create(const char *name,
     process->pid = simix_process_count++;
     process->name = xbt_strdup(name);
     process->smx_host = host;
-    process->iwannadie = 0;
     process->data = data;
 
     VERB1("Create context %s", process->name);
@@ -192,7 +190,7 @@ void SIMIX_process_kill(smx_process_t process, smx_process_t killer) {
 
   DEBUG2("Killing process %s on %s", process->name, process->smx_host->name);
 
-  process->iwannadie = 1;
+  process->context->iwannadie = 1;
   process->blocked = 0;
   process->suspended = 0;
   /* FIXME: set doexception to 0 also? */
@@ -507,7 +505,7 @@ void SIMIX_process_yield(void)
   /* Ok, maestro returned control to us */
   DEBUG1("Maestro returned control to me: '%s'", self->name);
 
-  if (self->iwannadie)
+  if (self->context->iwannadie)
     SIMIX_context_stop(self->context);
 
   if (self->doexception) {