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

Private GIT Repository
Update attribute "credit" for each neighbor.
[loba.git] / process.cpp
index db84ff82704e4292284af6520e1986f838ee57f9..27c3a1bc9e1a9905ff2e26e1fe6eff3757058d57 100644 (file)
@@ -395,12 +395,18 @@ void process::handle_message(message* msg, m_host_t from)
     case message::CTRL: {
         neighbor* n = rev_neigh[from];
         n->set_load(msg->get_amount() + n->get_to_send());
     case message::CTRL: {
         neighbor* n = rev_neigh[from];
         n->set_load(msg->get_amount() + n->get_to_send());
-        expected_load += msg->get_credit(); // may be 0.0 if !opt::bookkeeping
+        if (opt::bookkeeping) {
+            double credit = msg->get_credit();
+            expected_load += credit;
+            n->set_credit(n->get_credit() + credit);
+        }
         break;
     }
     case message::DATA: {
         break;
     }
     case message::DATA: {
+        neighbor* n = rev_neigh[from];
         double ld = msg->get_amount();
         received_load += ld;
         double ld = msg->get_amount();
         received_load += ld;
+        n->set_credit(n->get_credit() - ld);
         break;
     }
     case message::CTRL_CLOSE:
         break;
     }
     case message::CTRL_CLOSE: