]> AND Private Git Repository - loba.git/commitdiff
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
Use MSG_comm_waitall for communicator::flush(true).
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Wed, 26 Jan 2011 12:39:08 +0000 (13:39 +0100)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Wed, 26 Jan 2011 13:52:57 +0000 (14:52 +0100)
It is cleaner and, with SG 3.5, it makes a deadlock vanish.

BUGS
communicator.cpp
process.cpp

diff --git a/BUGS b/BUGS
index ff54efcc2b141bb154acaa153968faa167e7cad9..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -1,3 +0,0 @@
-./loba cluster1000.xml -N64 -L100 -i100 -a fair -T hcube
-=> leads to deadlock (with stable)
-
index bcdce2fbda6d6dfda76e1558be50a62a68597925..e30d73187dc8e184ece920423ed33cca03e16454 100644 (file)
@@ -9,6 +9,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(comm);
 
 #include "misc.h"
 #include "options.h"
 
 #include "misc.h"
 #include "options.h"
+#include "simgrid_features.h"
 #include "tracing.h"
 
 #include "communicator.h"
 #include "tracing.h"
 
 #include "communicator.h"
@@ -128,21 +129,14 @@ bool communicator::recv(message*& msg, m_host_t& from, double timeout)
 
 void communicator::flush(bool wait)
 {
 
 void communicator::flush(bool wait)
 {
-    using std::tr1::bind;
-    using std::tr1::placeholders::_1;
-
     sent_comm.remove_if(comm_test_n_destroy);
     if (wait && !sent_comm.empty()) {
     sent_comm.remove_if(comm_test_n_destroy);
     if (wait && !sent_comm.empty()) {
-        xbt_dynar_t comms = xbt_dynar_new(sizeof(msg_comm_t), NULL);
-        while (!sent_comm.empty()) {
-            std::for_each(sent_comm.begin(), sent_comm.end(),
-                          bind(xbt_dynar_push,
-                               comms, bind(misc::address<msg_comm_t>(), _1)));
-            MSG_comm_waitany(comms);
-            xbt_dynar_reset(comms);
-            sent_comm.remove_if(comm_test_n_destroy);
-        }
-        xbt_dynar_free(&comms);
+        msg_comm_t comms[sent_comm.size()];
+        std::copy(sent_comm.begin(), sent_comm.end(), comms);
+        MSG_comm_waitall(comms, sent_comm.size(), -1.0);
+        if (!MSG_WAIT_DESTROYS_COMMS)
+            std::for_each(sent_comm.begin(), sent_comm.end(), MSG_comm_destroy);
+        sent_comm.clear();
     }
 }
 
     }
 }
 
index 99593765b8e8febfd374da6fc4116b684ce4cb07..57c06612ad84bb9cffaa07123e8c113b0148fad9 100644 (file)
@@ -315,10 +315,10 @@ void process::finalize()
     std::for_each(neigh.begin(), neigh.end(),
                   bind(&process::finalize1, this, _1));
 
     std::for_each(neigh.begin(), neigh.end(),
                   bind(&process::finalize1, this, _1));
 
-    DEBUG2("wait for CLOSE from %lu neighbor%s",
-           (unsigned long )neigh.size(), ESSE(neigh.size()));
     while (may_receive()) {
         comm.flush(false);
     while (may_receive()) {
         comm.flush(false);
+        DEBUG2("waiting for %d CTRL and %d DATA CLOSE",
+               ctrl_close_pending, data_close_pending);
         receive(-1.0);
     }
 
         receive(-1.0);
     }