Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Major bug fix in SURF.
[simgrid.git] / src / surf / cpu.c
index 5a5dc18..31307f6 100644 (file)
@@ -31,6 +31,7 @@ static cpu_t cpu_new(char *name, double power_scale,
   cpu->resource = (surf_resource_t) surf_cpu_resource;
   cpu->name = name;
   cpu->power_scale = power_scale;
+  xbt_assert0(cpu->power_scale>0,"Power has to be >0");
   cpu->power_current = power_initial;
   if (power_trace)
     cpu->power_event =
@@ -105,10 +106,9 @@ static int resource_used(void *resource_id)
 
 static void action_free(surf_action_t action)
 {
-  surf_action_cpu_t Action = (surf_action_cpu_t) action;
-
   xbt_swag_remove(action, action->state_set);
-  lmm_variable_free(maxmin_system, Action->variable);
+  if(((surf_action_cpu_t)action)->variable)
+    lmm_variable_free(maxmin_system, ((surf_action_cpu_t)action)->variable);
   xbt_free(action);
 
   return;
@@ -127,6 +127,12 @@ static void action_recycle(surf_action_t action)
 static void action_change_state(surf_action_t action,
                                e_surf_action_state_t state)
 {
+  if((state==SURF_ACTION_DONE) || (state==SURF_ACTION_FAILED))
+    if(((surf_action_cpu_t)action)->variable) {
+      lmm_variable_free(maxmin_system, ((surf_action_cpu_t)action)->variable);
+      ((surf_action_cpu_t)action)->variable = NULL;
+    }
+
   surf_action_change_state(action, state);
   return;
 }