From: Francis Dupont Date: Mon, 10 Dec 2018 17:26:16 +0000 (+0100) Subject: [283-perfdhcp-fix-send-due] Fixed late sent flag (second try) X-Git-Tag: 283-perfdhcp-sending-thread_base~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b4bd744997e85c6772254883d5f59bf9ccd3110b;p=thirdparty%2Fkea.git [283-perfdhcp-fix-send-due] Fixed late sent flag (second try) --- diff --git a/src/bin/perfdhcp/rate_control.cc b/src/bin/perfdhcp/rate_control.cc index a61cd5840d..8e10b8e9b0 100644 --- a/src/bin/perfdhcp/rate_control.cc +++ b/src/bin/perfdhcp/rate_control.cc @@ -108,12 +108,14 @@ RateControl::updateSendDue() { send_due_ = start_time_ + time_duration(0, 0, static_cast(seconds), static_cast(fracts)); - // Compute the time of the last due. - offset = 1. / getRate(); - fracts = offset * time_duration::ticks_per_second(); - boost::posix_time::ptime last_due = - send_due_ - time_duration(0, 0, 0, static_cast(fracts)); - if (last_due > currentTime()) { + // Compute the number of packets we should have sent. + boost::posix_time::time_period period(start_time_, currentTime()); + boost::posix_time::time_duration duration = period.length(); + offset = static_cast(duration.ticks()) / + time_duration::ticks_per_second(); + uint64_t should_sent = + static_cast(getRate() * offset) - 1; + if (should_sent > sent_) { late_sent_ = true; } else { late_sent_ = false;