Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
make simix more resilient to PEBKAC
[simgrid.git] / src / simix / smx_global.c
index 9f66e79..3491894 100644 (file)
@@ -206,7 +206,6 @@ void SIMIX_global_init(int *argc, char **argv)
     simix_timers = xbt_heap_new(8, &free);
   }
 
-  sg_host_init();
   SIMIX_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, SIMIX_storage_destroy);
 
   if (sg_cfg_get_boolean("clean_atexit"))
@@ -243,7 +242,14 @@ void SIMIX_clean(void)
 #endif
   if (cleaned) return; // to avoid double cleaning by java and C
   cleaned = 1;
-  /* Kill everyone (except maestro) */
+  XBT_DEBUG("SIMIX_clean called. Simulation's over.");
+  if (!xbt_dynar_is_empty(simix_global->process_to_run) && SIMIX_get_clock() == 0.0) {
+         XBT_CRITICAL("   ");
+         XBT_CRITICAL("The time is still 0, and you still have processes ready to run.");
+         XBT_CRITICAL("It seems that you forgot to run the simulation that you setup.");
+         xbt_die("Bailing out to avoid that stop-before-start madness. Please fix your code.");
+  }
+  /* Kill all processes (but maestro) */
   SIMIX_process_killall(simix_global->maestro_process, 1);
 
   /* Exit the SIMIX network module */
@@ -486,7 +492,7 @@ void SIMIX_run(void)
       char *hostname = NULL;
       xbt_dynar_foreach(host_that_restart,iter,hostname) {
         XBT_INFO("Restart processes on host: %s",hostname);
-        SIMIX_host_autorestart(SIMIX_host_get_by_name(hostname));
+        SIMIX_host_autorestart(sg_host_by_name(hostname));
       }
       xbt_dynar_reset(host_that_restart);
     }