Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Rename simgrid::exception into simgrid::Exception
[simgrid.git] / teshsuite / msg / host_on_off_processes / host_on_off_processes.cpp
index a10f8b7..fb7751d 100644 (file)
@@ -3,8 +3,8 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "simgrid/Exception.hpp"
 #include "simgrid/msg.h"
-#include <xbt/ex.hpp>
 
 #include <stdio.h> /* sscanf */
 
@@ -19,7 +19,7 @@ static void task_cleanup_handler(void* task)
     MSG_task_destroy(static_cast<msg_task_t>(task));
 }
 
-static int process_daemon(int argc, char* argv[])
+static int process_daemon(int /*argc*/, char** /*argv*/)
 {
   msg_process_t self = MSG_process_self();
   XBT_INFO("  Start daemon on %s (%f)", MSG_host_get_name(MSG_host_self()), MSG_host_get_speed(MSG_host_self()));
@@ -27,16 +27,19 @@ static int process_daemon(int argc, char* argv[])
     msg_task_t task = MSG_task_create("daemon", MSG_host_get_speed(MSG_host_self()), 0, NULL);
     MSG_process_set_data(self, task);
     XBT_INFO("  Execute daemon");
-    MSG_task_execute(task);
-    MSG_process_set_data(self, NULL);
+    msg_error_t res = MSG_task_execute(task);
     MSG_task_destroy(task);
     tasks_done++;
+    if (res == MSG_HOST_FAILURE) {
+      XBT_INFO("Host as died as expected, do nothing else");
+      return 0;
+    }
   }
   XBT_INFO("  daemon done. See you!");
   return 0;
 }
 
-static int process_sleep(int argc, char* argv[])
+static int process_sleep(int /*argc*/, char** /*argv*/)
 {
   for (;;) {
     XBT_INFO("  I'm alive but I should sleep");
@@ -46,7 +49,7 @@ static int process_sleep(int argc, char* argv[])
   return 0;
 }
 
-static int commTX(int argc, char* argv[])
+static int commTX(int /*argc*/, char** /*argv*/)
 {
   const char* mailbox = "comm";
   XBT_INFO("  Start TX");
@@ -67,7 +70,7 @@ static int commTX(int argc, char* argv[])
   return 0;
 }
 
-static int commRX(int argc, char* argv[])
+static int commRX(int /*argc*/, char** /*argv*/)
 {
   msg_task_t task     = NULL;
   const char* mailbox = "comm";
@@ -87,7 +90,7 @@ static int commRX(int argc, char* argv[])
   return 0;
 }
 
-static int test_launcher(int argc, char* argv[])
+static int test_launcher(int /*argc*/, char** /*argv*/)
 {
   int test = 0;
   char** argvF;
@@ -247,7 +250,6 @@ int main(int argc, char* argv[])
 
   MSG_create_environment(argv[1]);
 
-  MSG_process_set_data_cleanup(task_cleanup_handler);
   MSG_process_create("test_launcher", test_launcher, NULL, MSG_get_host_by_name("Tremblay"));
 
   res = MSG_main();