24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-06-18 22:15:20 +02:00

Let shaper cope with low resolution system clock

We no longer rely on getting unique values from clock source, so we need
to handle cope with systems which does not have a microsecond resolution
on system clock (such as MS Windows)
This commit is contained in:
Christophe Romain 2016-04-29 10:57:34 +02:00
parent 639c2fb640
commit 6a10916dda

View File

@ -124,9 +124,13 @@ update(#maxrate{} = State, Size) ->
true -> 0 true -> 0
end, end,
NextNow = p1_time_compat:system_time(micro_seconds) + Pause * 1000, 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 =
(State#maxrate.lastrate + (State#maxrate.lastrate +
1000000 * Size / (NextNow - State#maxrate.lasttime)) 1000000 * Size / Div)
/ 2, / 2,
lasttime = NextNow}, lasttime = NextNow},
Pause}. Pause}.