Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
yet another bunch of critical
[simgrid.git] / examples / msg / cloud-masterworker / cloud-masterworker.c
index 0137bdf..ab01626 100644 (file)
@@ -47,14 +47,11 @@ static int worker_fun(int argc, char *argv[])
     msg_task_t task = NULL;
 
     msg_error_t res = MSG_task_receive(&task, mbox);
-    if (res != MSG_OK) {
-      XBT_CRITICAL("MSG_task_get failed");
-      DIE_IMPOSSIBLE;
-    }
+    xbt_assert(res == MSG_OK, "MSG_task_get failed");
 
     XBT_INFO("%s received task(%s) from mailbox(%s)", pr_name, MSG_task_get_name(task), mbox);
 
-    if (!strcmp(MSG_task_get_name(task), "finalize")) {
+    if (strcmp(MSG_task_get_name(task), "finalize") == 0) {
       MSG_task_destroy(task);
       break;
     }
@@ -108,8 +105,7 @@ static int master_fun(int argc, char *argv[])
 
   XBT_INFO("# Suspend all VMs");
   xbt_dynar_foreach(vms, i, vm) {
-    const char *vm_name = MSG_host_get_name(vm);
-    XBT_INFO("suspend %s", vm_name);
+    XBT_INFO("suspend %s", MSG_host_get_name(vm));
     MSG_vm_suspend(vm);
   }
 
@@ -153,7 +149,7 @@ static int master_fun(int argc, char *argv[])
     MSG_vm_migrate(vm, worker_pm1);
   }
 
-  XBT_INFO("# Shutdown the half of worker processes gracefuly. The remaining half will be forcibly killed.");
+  XBT_INFO("# Shutdown the half of worker processes gracefully. The remaining half will be forcibly killed.");
   for (i = 0; i < nb_workers; i++) {
     char mbox[MAXMBOXLEN];
     snprintf(mbox, MAXMBOXLEN, "MBOX:WRK%02d", i);
@@ -202,6 +198,7 @@ int main(int argc, char *argv[])
     msg_host_t pm = xbt_dynar_get_as(pms, i, msg_host_t);
     xbt_dynar_push(worker_pms, &pm);
   }
+  xbt_dynar_free(&pms);
 
   /* Start the master process on the master pm. */
   MSG_process_create("master", master_fun, worker_pms, master_pm);
@@ -210,7 +207,6 @@ int main(int argc, char *argv[])
   XBT_INFO("Bye (simulation time %g)", MSG_get_clock());
 
   xbt_dynar_free(&worker_pms);
-  xbt_dynar_free(&pms);
 
   return !(res == MSG_OK);
 }