From 7434f41ee4c61ab7d5786f2eb91d0693949c39bd Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Fri, 30 Nov 2012 08:50:03 +0500 Subject: mod_storage_sql: Return actual error string on commit failure. --- plugins/mod_storage_sql.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua index f6fa94e7..eed3fec9 100644 --- a/plugins/mod_storage_sql.lua +++ b/plugins/mod_storage_sql.lua @@ -228,7 +228,8 @@ local function rollback(...) return ...; end local function commit(...) - if not connection:commit() then return nil, "SQL commit failed"; end + local success,err = connection:commit(); + if not success then return nil, "SQL commit failed: "..tostring(err); end return ...; end -- cgit v1.2.3 From 86d98527ee00dd466994470dabbe1954bbc81351 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Fri, 30 Nov 2012 08:57:58 +0500 Subject: MUC: Expose create_room(jid). --- plugins/muc/mod_muc.lua | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/plugins/muc/mod_muc.lua b/plugins/muc/mod_muc.lua index bf29d1ca..0df8b790 100644 --- a/plugins/muc/mod_muc.lua +++ b/plugins/muc/mod_muc.lua @@ -77,17 +77,22 @@ local function room_save(room, forced) if forced then datamanager.store(nil, muc_host, "persistent", persistent_rooms); end end +function create_room(jid) + local room = muc_new_room(jid); + room.route_stanza = room_route_stanza; + room.save = room_save; + rooms[jid] = room; + return room; +end + local persistent_errors = false; for jid in pairs(persistent_rooms) do local node = jid_split(jid); local data = datamanager.load(node, muc_host, "config"); if data then - local room = muc_new_room(jid); + local room = create_room(jid); room._data = data._data; room._affiliations = data._affiliations; - room.route_stanza = room_route_stanza; - room.save = room_save; - rooms[jid] = room; else -- missing room data persistent_rooms[jid] = nil; module:log("error", "Missing data for room '%s', removing from persistent room list", jid); @@ -149,10 +154,7 @@ function stanza_handler(event) if not(restrict_room_creation) or (restrict_room_creation == "admin" and is_admin(stanza.attr.from)) or (restrict_room_creation == "local" and select(2, jid_split(stanza.attr.from)) == module.host:gsub("^[^%.]+%.", "")) then - room = muc_new_room(bare); - room.route_stanza = room_route_stanza; - room.save = room_save; - rooms[bare] = room; + room = create_room(bare); end end if room then @@ -190,14 +192,11 @@ module.save = function() end module.restore = function(data) for jid, oldroom in pairs(data.rooms or {}) do - local room = muc_new_room(jid); + local room = create_room(jid); room._jid_nick = oldroom._jid_nick; room._occupants = oldroom._occupants; room._data = oldroom._data; room._affiliations = oldroom._affiliations; - room.route_stanza = room_route_stanza; - room.save = room_save; - rooms[jid] = room; end hosts[module:get_host()].muc = { rooms = rooms }; end -- cgit v1.2.3 From d2b8f935c6abdab0c44375ffe110e32dedbe0b26 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Fri, 30 Nov 2012 09:05:51 +0500 Subject: sessionmanager: Log the actual error message when roster loading fails. --- core/sessionmanager.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index 6945b8de..d505492e 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -185,6 +185,7 @@ function bind_resource(session, resource) bare_sessions[session.username..'@'..session.host] = nil; hosts[session.host].sessions[session.username] = nil; end + session.log("error", "Roster loading failed: %s", err); return nil, "cancel", "internal-server-error", "Error loading roster"; end -- cgit v1.2.3