diff options
| author | Gordon Sim <gsim@apache.org> | 2008-10-23 08:24:05 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2008-10-23 08:24:05 +0000 |
| commit | 6e6674c08ba4d73ae161016cde2aae16f5b4d392 (patch) | |
| tree | 1c27a5b82c242b2ba962415b0ac0ab6add705cb5 /qpid/cpp/src | |
| parent | 3a07c0d1d6f665ae0d5b308fa8a3342d2bf4b1c2 (diff) | |
| download | qpid-python-6e6674c08ba4d73ae161016cde2aae16f5b4d392.tar.gz | |
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@707308 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src')
| -rw-r--r-- | qpid/cpp/src/qpid/broker/RateTracker.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/qpid/cpp/src/qpid/broker/RateTracker.cpp b/qpid/cpp/src/qpid/broker/RateTracker.cpp index 5377bcfc0b..f7bf0a8ff0 100644 --- a/qpid/cpp/src/qpid/broker/RateTracker.cpp +++ b/qpid/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 |
