summaryrefslogtreecommitdiff
path: root/lib/common/RateLimitingStream.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/common/RateLimitingStream.cpp')
-rw-r--r--lib/common/RateLimitingStream.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/common/RateLimitingStream.cpp b/lib/common/RateLimitingStream.cpp
index 67a97e6b..8876f146 100644
--- a/lib/common/RateLimitingStream.cpp
+++ b/lib/common/RateLimitingStream.cpp
@@ -63,6 +63,14 @@ int RateLimitingStream::Read(void *pBuffer, int NBytes, int Timeout)
// How are we doing so far? (for logging only)
box_time_t currentDuration = currentTime - mStartTime;
+
+ // in case our timer is not very accurate, don't divide by zero on first pass
+ if(currentDuration == 0)
+ {
+ BOX_TRACE("Current rate not yet known, sending immediately");
+ return bytesReadThisTime;
+ }
+
uint64_t effectiveRateSoFar = (mTotalBytesRead * MICRO_SEC_IN_SEC_LL)
/ currentDuration;