Diff

core/xmlhandlers.lua @ 53:14ea0fe6ca86

Session destruction fixes, some debugging code while we fix the rest. Also change logger to be more useful.
author Matthew Wild <mwild1@gmail.com>
date Sat, 04 Oct 2008 15:25:54 +0100
parent 40:2c0147bbd81a
child 99:ba08b8a4eeef
line wrap: on
line diff
--- a/core/xmlhandlers.lua	Sat Oct 04 15:24:52 2008 +0100
+++ b/core/xmlhandlers.lua	Sat Oct 04 15:25:54 2008 +0100
@@ -10,6 +10,7 @@
 local t_remove = table.remove;
 local t_concat = table.concat;
 local t_concatall = function (t, sep) local tt = {}; for _, s in ipairs(t) do t_insert(tt, tostring(s)); end return t_concat(tt, sep); end
+local sm_destroy_session = import("core.sessionmanager", "destroy_session");
 
 local error = error;
 
@@ -60,7 +61,15 @@
 		end
 		function xml_handlers:EndElement(name)
 			curr_ns,name = name:match("^(.+):(%w+)$");
-			if (not stanza) or #stanza.last_add < 0 or (#stanza.last_add > 0 and name ~= stanza.last_add[#stanza.last_add].name) then error("XML parse error in client stream"); end
+			if (not stanza) or #stanza.last_add < 0 or (#stanza.last_add > 0 and name ~= stanza.last_add[#stanza.last_add].name) then 
+				if name == "stream" then
+					log("debug", "Stream closed");
+					sm_destroy_session(session);
+					return;
+				else
+					error("XML parse error in client stream");
+				end
+			end
 			if stanza and #chardata > 0 then
 				-- We have some character data in the buffer
 				stanza:text(t_concat(chardata));