aboutsummaryrefslogtreecommitdiffstats
path: root/util/throttle.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-07-28 01:14:31 +0100
committerMatthew Wild <mwild1@gmail.com>2012-07-28 01:14:31 +0100
commit81bef2c93b53e006cbeebdffc80040af6b4daf68 (patch)
tree2732225257e7b8ade28695dad7c0df3f7cea00b1 /util/throttle.lua
parent8eec29745633bd84c2d325d42dbeeb4afd37d516 (diff)
parent47619af14cd24fcb48b4d2b4c4653f72b882087e (diff)
downloadprosody-81bef2c93b53e006cbeebdffc80040af6b4daf68.tar.gz
prosody-81bef2c93b53e006cbeebdffc80040af6b4daf68.zip
Merge with Florob
Diffstat (limited to 'util/throttle.lua')
-rw-r--r--util/throttle.lua3
1 files changed, 2 insertions, 1 deletions
diff --git a/util/throttle.lua b/util/throttle.lua
index 2e901158..55e1d07b 100644
--- a/util/throttle.lua
+++ b/util/throttle.lua
@@ -1,6 +1,7 @@
local gettime = require "socket".gettime;
local setmetatable = setmetatable;
+local floor = math.floor;
module "throttle"
@@ -11,7 +12,7 @@ function throttle:update()
local newt = gettime();
local elapsed = newt - self.t;
self.t = newt;
- local balance = self.rate * elapsed + self.balance;
+ local balance = floor(self.rate * elapsed) + self.balance;
if balance > self.max then
self.balance = self.max;
else