aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-07-09 02:36:09 +0100
committerMatthew Wild <mwild1@gmail.com>2012-07-09 02:36:09 +0100
commit9462cf30c6b16db4b6ac9814f8b06ede8611ccae (patch)
tree42e54661043d57357f9a0f163fc92702143d3252 /util
parentfaa67b9d90d5ef2c8b5db346649f0d8d06d3e603 (diff)
parent90806a87a4b01496b4867f18c8860a52af55db9d (diff)
downloadprosody-9462cf30c6b16db4b6ac9814f8b06ede8611ccae.tar.gz
prosody-9462cf30c6b16db4b6ac9814f8b06ede8611ccae.zip
Merge 0.9->trunk
Diffstat (limited to 'util')
-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