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

Private GIT Repository
Update attribute "credit" for each neighbor.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Mon, 19 Sep 2011 12:57:48 +0000 (14:57 +0200)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Mon, 19 Sep 2011 14:53:54 +0000 (16:53 +0200)
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());
-        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: {
+        neighbor* n = rev_neigh[from];
         double ld = msg->get_amount();
         received_load += ld;
+        n->set_credit(n->get_credit() - ld);
         break;
     }
     case message::CTRL_CLOSE: