Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/simgrid/simgrid
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 22 Feb 2019 11:08:29 +0000 (12:08 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 22 Feb 2019 11:08:29 +0000 (12:08 +0100)
src/msg/msg_gos.cpp
src/s4u/s4u_Comm.cpp
teshsuite/msg/task_destroy_cancel/task_destroy_cancel.cpp

index 04a9e01..9573554 100644 (file)
@@ -456,6 +456,9 @@ int MSG_comm_test(msg_comm_t comm)
   } catch (simgrid::TimeoutError& e) {
     comm->status = MSG_TIMEOUT;
     finished     = true;
+  } catch (simgrid::CancelException& e) {
+    comm->status = MSG_HOST_FAILURE;
+    finished     = true;
   }
   catch (xbt_ex& e) {
     if (e.category == network_error) {
@@ -495,6 +498,9 @@ int MSG_comm_testany(xbt_dynar_t comms)
   } catch (simgrid::TimeoutError& e) {
     finished_index = e.value;
     status         = MSG_TIMEOUT;
+  } catch (simgrid::CancelException& e) {
+    finished_index = e.value;
+    status         = MSG_HOST_FAILURE;
   }
   catch (xbt_ex& e) {
     if (e.category != network_error)
@@ -544,6 +550,8 @@ msg_error_t MSG_comm_wait(msg_comm_t comm, double timeout)
     /* FIXME: these functions are not traceable */
   } catch (simgrid::TimeoutError& e) {
     comm->status = MSG_TIMEOUT;
+  } catch (simgrid::CancelException& e) {
+    comm->status = MSG_HOST_FAILURE;
   }
   catch (xbt_ex& e) {
     if (e.category == network_error)
@@ -591,6 +599,9 @@ int MSG_comm_waitany(xbt_dynar_t comms)
   } catch (simgrid::TimeoutError& e) {
     finished_index = e.value;
     status         = MSG_TIMEOUT;
+  } catch (simgrid::CancelException& e) {
+    finished_index = e.value;
+    status         = MSG_HOST_FAILURE;
   }
   catch(xbt_ex& e) {
     if (e.category == network_error) {
index 7eb4685..c770e2c 100644 (file)
@@ -6,6 +6,7 @@
 #include "src/msg/msg_private.hpp"
 #include "xbt/log.h"
 
+#include "simgrid/Exception.hpp"
 #include "simgrid/s4u/Comm.hpp"
 #include "simgrid/s4u/Mailbox.hpp"
 
@@ -168,7 +169,8 @@ Comm* Comm::wait_for(double timeout)
       return this;
 
     case State::CANCELED:
-      return this;
+      throw CancelException(XBT_THROW_POINT, "Communication canceled");
+
     default:
       THROW_IMPOSSIBLE;
   }
index 0a6cd71..ed57228 100644 (file)
@@ -31,24 +31,16 @@ static int master(int /*argc*/, char* /*argv*/ [])
   msg_comm_t comm = MSG_task_isend(task, "worker_mailbox");
   XBT_INFO("Canceling task \"%s\" during comm", task->name);
   MSG_task_cancel(task);
-  try {
-    MSG_comm_wait(comm, -1);
-  }
-  catch (xbt_ex& ex) {
+  if (MSG_comm_wait(comm, -1) != MSG_OK)
     MSG_comm_destroy(comm);
-  }
   MSG_task_destroy(task);
 
   task = MSG_task_create("finalize", task_comp_size, task_comm_size, NULL);
   comm = MSG_task_isend(task, "worker_mailbox");
   XBT_INFO("Destroying task \"%s\" during comm", task->name);
   MSG_task_destroy(task);
-  try {
-    MSG_comm_wait(comm, -1);
-  }
-  catch (xbt_ex& ex) {
+  if (MSG_comm_wait(comm, -1) != MSG_OK)
     MSG_comm_destroy(comm);
-  }
 
   task = MSG_task_create("cancel", task_comp_size, task_comm_size, NULL);
   MSG_task_send_with_timeout(task, "worker_mailbox", timeout);