From f5336c506a2c288f6a4a9ed84ecb21b12a22a2dd Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Thu, 1 Sep 2011 23:31:50 +0200 Subject: [PATCH] Do not go below expected_load when bookkeeping. --- process.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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) -- 2.39.5