Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
factorize error testing in waitany with the one done in wait (actually performed...
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 10 May 2010 09:34:26 +0000 (09:34 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 10 May 2010 09:34:26 +0000 (09:34 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7726 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/simix/smx_network.c

index 465fba7..381602e 100644 (file)
@@ -569,33 +569,17 @@ unsigned int SIMIX_network_waitany(xbt_dynar_t comms) {
     SIMIX_process_yield();
   }
   
     SIMIX_process_yield();
   }
   
-  xbt_dynar_foreach(comms,cursor,comm){
+  xbt_dynar_foreach(comms,cursor,comm)
     xbt_dynar_push(sems,&(comm->sem));
     xbt_dynar_push(sems,&(comm->sem));
-  }
 
   DEBUG1("Waiting for the completion of communication set %p", comms);
 
   found_comm = SIMIX_sem_acquire_any(sems);
 
   DEBUG1("Waiting for the completion of communication set %p", comms);
 
   found_comm = SIMIX_sem_acquire_any(sems);
+  xbt_dynar_free_container(&sems);
   xbt_assert0(found_comm!=-1,"Cannot find which communication finished");
   xbt_dynar_get_cpy(comms,found_comm,&comm_finished);
 
   xbt_assert0(found_comm!=-1,"Cannot find which communication finished");
   xbt_dynar_get_cpy(comms,found_comm,&comm_finished);
 
-  DEBUG1("Communication %p complete! Let's check for errors", comm_finished);
-
-  /* Make sure that everyone sleeping on that semaphore is awake,
-   * and that nobody will ever block on it */
-  SIMIX_sem_release_forever(comm_finished->sem);
-
-  /* Check for errors */
-  if(!SIMIX_host_get_state(SIMIX_host_self())){
-    if(comm_finished->rdv)
-      SIMIX_rdv_remove(comm_finished->rdv, comm_finished);
-    SIMIX_communication_destroy(comm_finished);
-    THROW0(host_error, 0, "Host failed");
-  } else if (SIMIX_action_get_state(comm_finished->act) == SURF_ACTION_FAILED){
-    SIMIX_communication_destroy(comm_finished);
-    THROW0(network_error, 0, "Link failure");
-  }
-  SIMIX_communication_destroy(comm_finished);
-
+  /* Check for errors and cleanup the comm */
+  SIMIX_communication_wait_for_completion(comm_finished,-1);
   return found_comm;
 }
   return found_comm;
 }