From: Arnaud Giersch Date: Thu, 1 Sep 2011 21:31:50 +0000 (+0200) Subject: Do not go below expected_load when bookkeeping. X-Git-Tag: v0.1~18 X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/commitdiff_plain/f5336c506a2c288f6a4a9ed84ecb21b12a22a2dd?hp=-c Do not go below expected_load when bookkeeping. --- f5336c506a2c288f6a4a9ed84ecb21b12a22a2dd diff --git a/process.cpp b/process.cpp index e6ae2ab..04c08c0 100644 --- a/process.cpp +++ b/process.cpp @@ -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)