From e73a68034cbc4bd3425d6003c084ca6d4dd3a8c5 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 31 Aug 2016 11:45:06 +0100 Subject: storagemanager: Simplify function flow --- core/storagemanager.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'core') diff --git a/core/storagemanager.lua b/core/storagemanager.lua index 8d83f677..64ae13e3 100644 --- a/core/storagemanager.lua +++ b/core/storagemanager.lua @@ -153,12 +153,12 @@ function open(host, store, typ) if err == "unsupported-store" then if typ == "map" then -- Use shim on top of keyval store log("debug", "map storage driver unavailable, using shim on top of keyval store."); - return create_map_shim(host, store); + ret, err = create_map_shim(host, store); + else + log("debug", "Storage driver %s does not support store %s (%s), falling back to null driver", + driver_name, store, typ or ""); + ret, err = null_storage_driver, nil; end - log("debug", "Storage driver %s does not support store %s (%s), falling back to null driver", - driver_name, store, typ or ""); - ret = null_storage_driver; - err = nil; end end return ret, err; -- cgit v1.2.3 From 21f08b2dfe144c8988dfa1cfafe10d15687e3542 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 31 Aug 2016 11:50:41 +0100 Subject: storagemanager: Fire event when opening a store, and allow the returned store/err to be overridden --- core/storagemanager.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'core') diff --git a/core/storagemanager.lua b/core/storagemanager.lua index 64ae13e3..255a9a49 100644 --- a/core/storagemanager.lua +++ b/core/storagemanager.lua @@ -161,6 +161,11 @@ function open(host, store, typ) end end end + if ret then + local event_data = { host = host, store_name = store, store_type = typ, store = ret }; + prosody.hosts[host].fire_event("store-opened", event_data); + ret, err = event_data.store, event_data.store_err; + end return ret, err; end -- cgit v1.2.3 From 48e72a1d7ba60029163e904148300f1ed3a79d4c Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 31 Aug 2016 16:10:00 +0100 Subject: storagemanager: Fix for previous commit --- core/storagemanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core') diff --git a/core/storagemanager.lua b/core/storagemanager.lua index 255a9a49..319046b9 100644 --- a/core/storagemanager.lua +++ b/core/storagemanager.lua @@ -163,7 +163,7 @@ function open(host, store, typ) end if ret then local event_data = { host = host, store_name = store, store_type = typ, store = ret }; - prosody.hosts[host].fire_event("store-opened", event_data); + prosody.hosts[host].events.fire_event("store-opened", event_data); ret, err = event_data.store, event_data.store_err; end return ret, err; -- cgit v1.2.3 From e2dbea53b4aa078633e6270da25a633741d4ae23 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 31 Aug 2016 16:10:16 +0100 Subject: moduleapi: 'duration' became 'times' --- core/moduleapi.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core') diff --git a/core/moduleapi.lua b/core/moduleapi.lua index 21b2216c..ee1f3e60 100644 --- a/core/moduleapi.lua +++ b/core/moduleapi.lua @@ -412,7 +412,7 @@ function api:measure(name, stat_type) end function api:measure_object_event(events_object, event_name, stat_name) - local m = self:measure(stat_name or event_name, "duration"); + local m = self:measure(stat_name or event_name, "times"); local function handler(handlers, _event_name, _event_data) local finished = m(); local ret = handlers(_event_name, _event_data); -- cgit v1.2.3