From f8d8aad20fdaefb83f009f2ec8a0c2e1e25c790e Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 23 Oct 2008 08:24:05 +0000 Subject: Fixed to avoid division by zero when sampling more frequently than once per second. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@707308 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/broker/RateTracker.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'cpp/src/qpid') diff --git a/cpp/src/qpid/broker/RateTracker.cpp b/cpp/src/qpid/broker/RateTracker.cpp index 5377bcfc0b..f7bf0a8ff0 100644 --- a/cpp/src/qpid/broker/RateTracker.cpp +++ b/cpp/src/qpid/broker/RateTracker.cpp @@ -42,7 +42,10 @@ double RateTracker::sampleRatePerSecond() Duration interval(lastTime, now); lastCount = currentCount; lastTime = now; - return increment ? increment / (interval / TIME_SEC) : 0; + //if sampling at higher frequency than supported, will just return the number of increments + if (interval == 0) return increment; + else if (increment == 0) return 0; + else return increment / (interval / TIME_SEC); } }} // namespace qpid::broker -- cgit v1.2.1