aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2014-09-23 01:44:16 +0200
committerKim Alvefur <zash@zash.se>2014-09-23 01:44:16 +0200
commit19e5326754d02e3a35e14bbbf25ff1c8fed1098d (patch)
tree1e63192849a869212df2448f814cb37c91b04fe5
parentdee8f7fde4d5e23c0139c2a7bc2871929c0df246 (diff)
parentad7e3d7233cff3e34c11323ff5ec64aacb8f678c (diff)
downloadprosody-19e5326754d02e3a35e14bbbf25ff1c8fed1098d.tar.gz
prosody-19e5326754d02e3a35e14bbbf25ff1c8fed1098d.zip
Merge 0.10->trunk
-rw-r--r--core/moduleapi.lua4
-rw-r--r--core/modulemanager.lua2
-rw-r--r--util/random.lua8
3 files changed, 8 insertions, 6 deletions
diff --git a/core/moduleapi.lua b/core/moduleapi.lua
index e9609ed9..754d7497 100644
--- a/core/moduleapi.lua
+++ b/core/moduleapi.lua
@@ -390,7 +390,9 @@ function api:open_store(name, type)
return require"core.storagemanager".open(self.host, name or self.name, type);
end
-return function (mm)
+function api.init(mm)
modulemanager = mm;
return api;
end
+
+return api;
diff --git a/core/modulemanager.lua b/core/modulemanager.lua
index 198e208a..92372ac3 100644
--- a/core/modulemanager.lua
+++ b/core/modulemanager.lua
@@ -37,7 +37,7 @@ local _G = _G;
module "modulemanager"
-local api = _G.require "core.moduleapi"(_M); -- Module API container
+local api = _G.require "core.moduleapi".init(_M); -- Module API container
-- [host] = { [module] = module_env }
local modulemap = { ["*"] = {} };
diff --git a/util/random.lua b/util/random.lua
index ed5cdf4b..5938a94f 100644
--- a/util/random.lua
+++ b/util/random.lua
@@ -10,7 +10,7 @@ local tostring = tostring;
local os_time = os.time;
local os_clock = os.clock;
local ceil = math.ceil;
-local sha1 = require "util.hashes".sha1;
+local H = require "util.hashes".sha512;
local last_uniq_time = 0;
local function uniq_time()
@@ -21,7 +21,7 @@ local function uniq_time()
end
local function new_random(x)
- return sha1(x..os_clock()..tostring({}));
+ return H(x..os_clock()..tostring({}));
end
local buffer = new_random(uniq_time());
@@ -31,8 +31,8 @@ local function seed(x)
end
local function bytes(n)
- if #buffer < n then seed(uniq_time()); end
- local r = buffer:sub(0, n);
+ if #buffer < n+4 then seed(uniq_time()); end
+ local r = buffer:sub(1, n);
buffer = buffer:sub(n+1);
return r;
end