Author: gsim
Date: Thu Oct 23 01:24:05 2008
New Revision: 707308

URL: http://svn.apache.org/viewvc?rev=707308&view=rev
Log:
Fixed to avoid division by zero when sampling more frequently than once per 
second.


Modified:
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/RateTracker.cpp

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/RateTracker.cpp
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/RateTracker.cpp?rev=707308&r1=707307&r2=707308&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/RateTracker.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/RateTracker.cpp Thu Oct 23 
01:24:05 2008
@@ -42,7 +42,10 @@
     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


Reply via email to