Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Finally beat the communication failure leaks of MSG
authorthiery <thiery@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 25 Jan 2011 14:43:35 +0000 (14:43 +0000)
committerthiery <thiery@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 25 Jan 2011 14:43:35 +0000 (14:43 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9494 48e7efb5-ca39-0410-a469-dd3cf9ba447f

examples/msg/masterslave/masterslave_failure.c
src/msg/msg_mailbox.c

index 1629a0a..a9ce28a 100644 (file)
@@ -78,17 +78,21 @@ int master(int argc, char *argv[])
     } else if (a == MSG_HOST_FAILURE) {
       INFO0
           ("Gloups. The cpu on which I'm running just turned off!. See you!");
+      free(task->data);
+      MSG_task_destroy(task);
       free(slaves);
       return 0;
     } else if (a == MSG_TRANSFER_FAILURE) {
       INFO1
           ("Mmh. Something went wrong with '%s'. Nevermind. Let's keep going!",
            slaves[i % slaves_count]->name);
+      free(task->data);
       MSG_task_destroy(task);
     } else if (a == MSG_TIMEOUT) {
       INFO1
           ("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!",
            slaves[i % slaves_count]->name);
+      free(task->data);
       MSG_task_destroy(task);
     } else {
       INFO0("Hey ?! What's up ? ");
@@ -106,6 +110,8 @@ int master(int argc, char *argv[])
     if (a == MSG_HOST_FAILURE) {
       INFO0
           ("Gloups. The cpu on which I'm running just turned off!. See you!");
+      MSG_task_destroy(task);
+      free(slaves);
       return 0;
     } else if (a == MSG_TRANSFER_FAILURE) {
       INFO1("Mmh. Can't reach '%s'! Nevermind. Let's keep going!",
index 5de723a..3aa3a90 100644 (file)
@@ -72,7 +72,7 @@ MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, m_task_t * task,
 {
   xbt_ex_t e;
   MSG_error_t ret = MSG_OK;
-  smx_action_t comm = NULL;
+  volatile smx_action_t comm = NULL;
 #ifdef HAVE_TRACING
   double start_time = 0;
 #endif
@@ -98,7 +98,6 @@ MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, m_task_t * task,
     comm = SIMIX_req_comm_irecv(mailbox, task, NULL, NULL, NULL);
     SIMIX_req_comm_wait(comm, timeout);
     (*task)->simdata->comm = comm;
-    SIMIX_req_comm_destroy(comm);
     DEBUG2("Got task %s from %p",(*task)->name,mailbox);
     (*task)->simdata->isused=0;
   }
@@ -114,11 +113,13 @@ MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, m_task_t * task,
       ret = MSG_TIMEOUT;
       break;
     default:
-       xbt_backtrace_display(&e);
-      xbt_die(bprintf("Unhandled SIMIX network exception: %s", e.msg));
+      RETHROW;
     }
     xbt_ex_free(e);
   }
+  if (comm != NULL) {
+    SIMIX_req_comm_destroy(comm);
+  }
 
   if (ret != MSG_HOST_FAILURE &&
       ret != MSG_TRANSFER_FAILURE && ret != MSG_TIMEOUT) {
@@ -137,7 +138,7 @@ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, m_task_t task,
   MSG_error_t ret = MSG_OK;
   simdata_task_t t_simdata = NULL;
   m_process_t process = MSG_process_self();
-  smx_action_t comm;
+  volatile smx_action_t comm = NULL;
 #ifdef HAVE_TRACING
   int call_end = 0;
 #endif
@@ -147,7 +148,6 @@ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, m_task_t task,
   call_end = TRACE_msg_task_put_start(task);    //must be after CHECK_HOST()
 #endif
 
-
   /* Prepare the task to send */
   t_simdata = task->simdata;
   t_simdata->sender = process;
@@ -170,7 +170,6 @@ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, m_task_t task,
     SIMIX_req_set_category(comm, task->category);
 #endif
     SIMIX_req_comm_wait(comm, timeout);
-    SIMIX_req_comm_destroy(comm);
   }
 
   CATCH(e) {
@@ -185,7 +184,7 @@ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, m_task_t task,
       ret = MSG_TIMEOUT;
       break;
     default:
-      xbt_die(bprintf("Unhandled SIMIX network exception: %s", e.msg));
+      RETHROW;
     }
     xbt_ex_free(e);
 
@@ -193,6 +192,10 @@ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, m_task_t task,
     t_simdata->isused=0;
   }
 
+  if (comm != NULL) {
+    SIMIX_req_comm_destroy(comm);
+  }
+
   process->simdata->waiting_task = NULL;
 #ifdef HAVE_TRACING
   if (call_end)