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 | f8d8aad20fdaefb83f009f2ec8a0c2e1e25c790e (patch) | |
| tree | 7414553bf17584c0d44208cb4468d379c7dd97de /cpp/src/qpid | |
| parent | 673cb2f2eb5b8e9e6b8677fc4374ea49f34f194b (diff) | |
| download | qpid-python-f8d8aad20fdaefb83f009f2ec8a0c2e1e25c790e.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/qpid@707308 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid')
| -rw-r--r-- | cpp/src/qpid/broker/RateTracker.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
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 |
