From 162ec6e7763efa260523f5cf03f635159803947d Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Thu, 15 Mar 2012 16:46:52 +0100 Subject: [PATCH 1/1] Bug fix: credit can be negative. E.g. when a data message comes faster than its corresponding ctrl message. Check that it is not negative when computing balance. --- process.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/process.cpp b/process.cpp index 97f2a69..b5531b0 100644 --- a/process.cpp +++ b/process.cpp @@ -421,7 +421,11 @@ void process::data_send(neighbor& nb) else excess_load = real_load; - double balance = nb.get_debt() - nb.get_credit(); + double balance; + if (nb.get_credit() > 0.0) + balance = nb.get_debt() - nb.get_credit(); + else + balance = nb.get_debt(); load_to_send = std::min(excess_load, std::max(0.0, balance)); -- 2.39.5