aboutsummaryrefslogtreecommitdiffstats
path: root/net/http/server.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2015-12-03 14:59:55 +0000
committerMatthew Wild <mwild1@gmail.com>2015-12-03 14:59:55 +0000
commit2b9a7ef7b48519a64f64268f4b4169c601175e93 (patch)
tree0a45f803690602626615b39fd3c0b17e3df266e7 /net/http/server.lua
parentab8006e6152db2531cfc65fbfa4de95efa570d6d (diff)
parentd3b6588fd79e85777cf5c6af4fd870c297dc7daf (diff)
downloadprosody-2b9a7ef7b48519a64f64268f4b4169c601175e93.tar.gz
prosody-2b9a7ef7b48519a64f64268f4b4169c601175e93.zip
Merge 0.10->trunk
Diffstat (limited to 'net/http/server.lua')
-rw-r--r--net/http/server.lua10
1 files changed, 5 insertions, 5 deletions
diff --git a/net/http/server.lua b/net/http/server.lua
index ffcceabe..acfb8a1d 100644
--- a/net/http/server.lua
+++ b/net/http/server.lua
@@ -27,7 +27,10 @@ local function is_wildcard_match(wildcard_event, event)
return wildcard_event:sub(1, -2) == event:sub(1, #wildcard_event-1);
end
-local recent_wildcard_events, max_cached_wildcard_events = {}, 10000;
+local _handlers = events._handlers;
+local recent_wildcard_events = cache.new(10000, function (key, value)
+ rawset(_handlers, key, nil);
+end);
local event_map = events._event_map;
setmetatable(events._handlers, {
@@ -62,10 +65,7 @@ setmetatable(events._handlers, {
end
rawset(handlers, curr_event, handlers_array);
if not event_map[curr_event] then -- Only wildcard handlers match, if any
- table.insert(recent_wildcard_events, curr_event);
- if #recent_wildcard_events > max_cached_wildcard_events then
- rawset(handlers, table.remove(recent_wildcard_events, 1), nil);
- end
+ recent_wildcard_events:set(curr_event, true);
end
return handlers_array;
end;