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

Private GIT Repository
Do not go below expected_load when bookkeeping.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Thu, 1 Sep 2011 21:31:50 +0000 (23:31 +0200)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Thu, 1 Sep 2011 21:31:50 +0000 (23:31 +0200)
process.cpp

index e6ae2abcdbb2573950534161d56c338f8d512b5a..04c08c0a57bcb4771475c4f1849997c0b9c3ec22 100644 (file)
@@ -322,9 +322,14 @@ void process::data_send(neighbor& nb)
 {
     double load_to_send;
     if (opt::bookkeeping) {
-        load_to_send = compute_load_to_send(std::min(real_load, nb.get_debt()));
-        if (load_to_send > 0.0)
-            nb.set_debt(nb.get_debt() - load_to_send);
+        double excess_load = real_load - expected_load;
+        if (excess_load > 0.0) {
+            load_to_send = compute_load_to_send(std::min(excess_load,
+                                                         nb.get_debt()));
+            if (load_to_send > 0.0)
+                nb.set_debt(nb.get_debt() - load_to_send);
+        } else
+            load_to_send = 0.0;
     } else {
         load_to_send = compute_load_to_send(nb.get_to_send());
         if (load_to_send > 0.0)