From: Arnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Date: Mon, 19 Sep 2011 12:57:48 +0000 (+0200)
Subject: Update attribute "credit" for each neighbor.
X-Git-Tag: exp_20120216~50
X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/commitdiff_plain/7fda6bebf9fc5cd93a34234737bb57f605e765ed

Update attribute "credit" for each neighbor.
---

diff --git a/process.cpp b/process.cpp
index db84ff8..27c3a1b 100644
--- a/process.cpp
+++ b/process.cpp
@@ -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: