Changeset

5512:6ebea1e6795b

Merges all the way down
author Matthew Wild <mwild1@gmail.com>
date Tue, 23 Apr 2013 15:15:52 +0100
parents 5511:764bda4b28b8 (diff) 5501:12a42421bede (current diff)
children 5515:865d82f21d12
files
diffstat 6 files changed, 19 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/core/storagemanager.lua	Fri Apr 19 16:16:09 2013 +0200
+++ b/core/storagemanager.lua	Tue Apr 23 15:15:52 2013 +0100
@@ -86,7 +86,7 @@
 	if not ret then
 		if err == "unsupported-store" then
 			log("debug", "Storage driver %s does not support store %s (%s), falling back to null driver",
-				driver_name, store, typ);
+				driver_name, store, typ or "<nil>");
 			ret = null_storage_driver;
 			err = nil;
 		end
--- a/net/http.lua	Fri Apr 19 16:16:09 2013 +0200
+++ b/net/http.lua	Tue Apr 23 15:15:52 2013 +0100
@@ -17,9 +17,9 @@
 local server = require "net.server"
 
 local t_insert, t_concat = table.insert, table.concat;
-local pairs, ipairs = pairs, ipairs;
-local tonumber, tostring, xpcall, select, debug_traceback, char, format =
-      tonumber, tostring, xpcall, select, debug.traceback, string.char, string.format;
+local pairs = pairs;
+local tonumber, tostring, xpcall, select, traceback =
+      tonumber, tostring, xpcall, select, debug.traceback;
 
 local log = require "util.logger".init("http");
 
@@ -101,7 +101,7 @@
 	request.parser:feed(data);
 end
 
-local function handleerr(err) log("error", "Traceback[http]: %s: %s", tostring(err), debug_traceback()); end
+local function handleerr(err) log("error", "Traceback[http]: %s", traceback(tostring(err), 2)); end
 function request(u, ex, callback)
 	local req = url.parse(u);
 	
--- a/net/http/server.lua	Fri Apr 19 16:16:09 2013 +0200
+++ b/net/http/server.lua	Tue Apr 23 15:15:52 2013 +0100
@@ -9,7 +9,7 @@
 local s_upper = string.upper;
 local setmetatable = setmetatable;
 local xpcall = xpcall;
-local debug = debug;
+local traceback = debug.traceback;
 local tostring = tostring;
 local codes = require "net.http.codes";
 
@@ -27,8 +27,11 @@
 	return wildcard_event:sub(1, -2) == event:sub(1, #wildcard_event-1);
 end
 
+local recent_wildcard_events, max_cached_wildcard_events = {}, 10000;
+
 local event_map = events._event_map;
 setmetatable(events._handlers, {
+	-- Called when firing an event that doesn't exist (but may match a wildcard handler)
 	__index = function (handlers, curr_event)
 		if is_wildcard_event(curr_event) then return; end -- Wildcard events cannot be fired
 		-- Find all handlers that could match this event, sort them
@@ -58,6 +61,12 @@
 			handlers_array = false;
 		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
+		end
 		return handlers_array;
 	end;
 	__newindex = function (handlers, curr_event, handlers_array)
@@ -79,7 +88,7 @@
 local function _handle_request() return handle_request(_1, _2, _3); end
 
 local last_err;
-local function _traceback_handler(err) last_err = err; log("error", "Traceback[http]: %s: %s", tostring(err), debug.traceback()); end
+local function _traceback_handler(err) last_err = err; log("error", "Traceback[httpserver]: %s", traceback(tostring(err), 2)); end
 events.add_handler("http-error", function (error)
 	return "Error processing request: "..codes[error.code]..". Check your error log for more information.";
 end, -1);
--- a/plugins/mod_auth_internal_plain.lua	Fri Apr 19 16:16:09 2013 +0200
+++ b/plugins/mod_auth_internal_plain.lua	Tue Apr 23 15:15:52 2013 +0100
@@ -19,7 +19,7 @@
 log("debug", "initializing internal_plain authentication provider for host '%s'", host);
 
 function provider.test_password(username, password)
-	log("debug", "test password '%s' for user %s at host %s", password, username, host);
+	log("debug", "test password for user %s at host %s", username, host);
 	local credentials = accounts:get(username) or {};
 
 	if password == credentials.password then
--- a/plugins/mod_c2s.lua	Fri Apr 19 16:16:09 2013 +0200
+++ b/plugins/mod_c2s.lua	Tue Apr 23 15:15:52 2013 +0100
@@ -116,7 +116,7 @@
 	end
 end
 
-local function handleerr(err) log("error", "Traceback[c2s]: %s: %s", tostring(err), traceback()); end
+local function handleerr(err) log("error", "Traceback[c2s]: %s", traceback(tostring(err), 2)); end
 function stream_callbacks.handlestanza(session, stanza)
 	stanza = session.filter("stanzas/in", stanza);
 	if stanza then
--- a/plugins/mod_s2s/mod_s2s.lua	Fri Apr 19 16:16:09 2013 +0200
+++ b/plugins/mod_s2s/mod_s2s.lua	Tue Apr 23 15:15:52 2013 +0100
@@ -429,7 +429,7 @@
 	end
 end
 
-local function handleerr(err) log("error", "Traceback[s2s]: %s: %s", tostring(err), traceback()); end
+local function handleerr(err) log("error", "Traceback[s2s]: %s", traceback(tostring(err), 2)); end
 function stream_callbacks.handlestanza(session, stanza)
 	if stanza.attr.xmlns == "jabber:client" then --COMPAT: Prosody pre-0.6.2 may send jabber:client
 		stanza.attr.xmlns = nil;