Changeset

1727:8f12afb633ec

mod_storage_xmlarchive: Attempt to recover after parse failures
author Kim Alvefur <zash@zash.se>
date Mon, 11 May 2015 14:17:35 +0200
parents 1726:160c35d2a5a2
children 1728:a51beeb5aecf
files mod_storage_xmlarchive/mod_storage_xmlarchive.lua
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_storage_xmlarchive/mod_storage_xmlarchive.lua	Mon May 11 14:16:23 2015 +0200
+++ b/mod_storage_xmlarchive/mod_storage_xmlarchive.lua	Mon May 11 14:17:35 2015 +0200
@@ -69,7 +69,13 @@
 	local stream = new_stream(stream_sess, { handlestanza = cb, stream_ns = "jabber:client"});
 	local dates = dm.list_load(username, module.host, self.store) or empty;
 	stream:feed(st.stanza("stream", { xmlns = "jabber:client" }):top_tag());
-	stream_sess.notopen = nil;
+	local function reset_stream()
+		stream:reset();
+		stream_sess.notopen = true;
+		stream:feed(st.stanza("stream", { xmlns = "jabber:client" }):top_tag());
+		stream_sess.notopen = nil;
+	end
+	reset_stream();
 
 	local limit = query.limit;
 	local start_day, step, last_day = 1, 1, #dates;
@@ -140,6 +146,7 @@
 					local ok, err = stream:feed(data);
 					if not ok then
 						module:log("warn", "Parse error in %s at %d+%d: %s", filename, item.offset, item.length, err);
+						reset_stream();
 					end
 					if result then
 						local stanza = result;