summaryrefslogtreecommitdiff
path: root/src/shaper.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/shaper.erl')
-rw-r--r--src/shaper.erl6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/shaper.erl b/src/shaper.erl
index a136c213..eb82b8fa 100644
--- a/src/shaper.erl
+++ b/src/shaper.erl
@@ -124,9 +124,13 @@ update(#maxrate{} = State, Size) ->
true -> 0
end,
NextNow = p1_time_compat:system_time(micro_seconds) + Pause * 1000,
+ Div = case NextNow - State#maxrate.lasttime of
+ 0 -> 1;
+ V -> V
+ end,
{State#maxrate{lastrate =
(State#maxrate.lastrate +
- 1000000 * Size / (NextNow - State#maxrate.lasttime))
+ 1000000 * Size / Div)
/ 2,
lasttime = NextNow},
Pause}.