aboutsummaryrefslogtreecommitdiffstats
path: root/net/http
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-04-27 20:00:06 +0100
committerMatthew Wild <mwild1@gmail.com>2012-04-27 20:00:06 +0100
commit53a4656587ab75f31bcf2437f3b36b3c41c01e5c (patch)
tree1fa1f5f7b8abb35a9c829ba629769a663e9384b1 /net/http
parent15b5936dc0c7fa70d003161b9db20a0ac83a0061 (diff)
downloadprosody-53a4656587ab75f31bcf2437f3b36b3c41c01e5c.tar.gz
prosody-53a4656587ab75f31bcf2437f3b36b3c41c01e5c.zip
net.http.server: Correctly cache results of handler indexing, and also cache failures
Diffstat (limited to 'net/http')
-rw-r--r--net/http/server.lua24
1 files changed, 14 insertions, 10 deletions
diff --git a/net/http/server.lua b/net/http/server.lua
index d693fb52..00d98fcb 100644
--- a/net/http/server.lua
+++ b/net/http/server.lua
@@ -46,17 +46,20 @@ setmetatable(events._handlers, {
end
end
end
- if #handlers_array == 0 then return; end
- table.sort(handlers_array, function(b, a)
- local a_score, b_score = matching_handlers_set[a], matching_handlers_set[b];
- for i = 1, #a_score do
- if a_score[i] ~= b_score[i] then -- If equal, compare next score value
- return a_score[i] < b_score[i];
+ if #handlers_array > 0 then
+ table.sort(handlers_array, function(b, a)
+ local a_score, b_score = matching_handlers_set[a], matching_handlers_set[b];
+ for i = 1, #a_score do
+ if a_score[i] ~= b_score[i] then -- If equal, compare next score value
+ return a_score[i] < b_score[i];
+ end
end
- end
- return false;
- end);
- handlers[curr_event] = handlers_array;
+ return false;
+ end);
+ else
+ handlers_array = false;
+ end
+ rawset(handlers, curr_event, handlers_array);
return handlers_array;
end;
__newindex = function (handlers, curr_event, handlers_array)
@@ -69,6 +72,7 @@ setmetatable(events._handlers, {
end
end
end
+ rawset(handlers, curr_event, handlers_array);
end;
});