From 7fda6bebf9fc5cd93a34234737bb57f605e765ed Mon Sep 17 00:00:00 2001
From: Arnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Date: Mon, 19 Sep 2011 14:57:48 +0200
Subject: [PATCH] Update attribute "credit" for each neighbor.

---
 process.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

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:
-- 
2.39.5