Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Warn processes killed because their host was turned off.
[simgrid.git] / teshsuite / msg / host_on_off_recv / host_on_off_recv.c
index 92e4ec0..9755c8d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2015. The SimGrid Team.
+/* Copyright (c) 2010-2018. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -12,57 +12,44 @@ static const char* mailbox = "comm";
 
 static int master(int argc, char *argv[])
 {
-  xbt_ex_t e;
-  TRY {
-    msg_host_t jupiter = MSG_host_by_name("Jupiter");
-    
-    XBT_INFO("Master starting");
-    MSG_process_sleep(0.5);
-
-    msg_comm_t comm = NULL;
-    {
-      msg_task_t task = MSG_task_create("COMM", 0, 100000000, NULL);
-      comm = MSG_task_isend(task, mailbox);
-    }
-
-    MSG_process_sleep(0.5);
-
-    XBT_INFO("Turning off the slave host");
-    MSG_host_off(jupiter);
-
-    if (comm) {
-      MSG_comm_wait(comm, -1);
-      MSG_comm_destroy(comm);
-    }
-    XBT_INFO("Master has finished");
-  }
-  CATCH(e) {
-    xbt_die("Exception caught in the master");
-    return 1;
+  msg_host_t jupiter = MSG_host_by_name("Jupiter");
+
+  XBT_INFO("Master starting");
+  MSG_process_sleep(0.5);
+
+  msg_task_t task = MSG_task_create("COMM", 0, 100000000, NULL);
+  msg_comm_t comm = MSG_task_isend(task, mailbox);
+
+  MSG_process_sleep(0.5);
+
+  XBT_INFO("Turning off the slave host");
+  MSG_host_off(jupiter);
+
+  if (comm) {
+    MSG_task_destroy(task);
+    MSG_comm_wait(comm, -1);
+    MSG_comm_destroy(comm);
   }
+  XBT_INFO("Master has finished");
+
   return 0;
 }
 
 static int slave(int argc, char *argv[])
 {
-  xbt_ex_t e;
-  TRY {
-    XBT_INFO("Slave receiving");
-    msg_task_t task = NULL;
-    msg_error_t error = MSG_task_receive(&(task), mailbox);
-    if (error) {
+  XBT_INFO("Slave receiving");
+  msg_task_t task = NULL;
+  msg_error_t error = MSG_task_receive(&(task), mailbox);
+  if (error) {
+    if (error != MSG_HOST_FAILURE)
       XBT_ERROR("Error while receiving message");
-      return 1;
-    }
-
-    XBT_ERROR("Slave should be off already.");
-    return 1;
-  }
-  CATCH(e) {
-    XBT_ERROR("Exception caught in the slave");
+    else
+      XBT_DEBUG("The host has been turned off, this was expected");
     return 1;
   }
-  return 0;
+
+  XBT_ERROR("Slave should be off already.");
+  return 1;
 }
 
 int main(int argc, char *argv[])