Comparison

plugins/mod_bosh.lua @ 5727:372ecf3630cf

mod_bosh: pcall() core_process_stanza per stanza, to bring in line with other listeners. This ensures that stanzas following a traceback-causing stanza in a request will still be processed (as would happen on normal c2s).
author Matthew Wild <mwild1@gmail.com>
date Mon, 08 Jul 2013 23:59:27 +0100
parent 5726:3bccc68a38e3
child 5729:8de1f9290588
child 8093:8d1fd6d34bda
comparison
equal deleted inserted replaced
5726:3bccc68a38e3 5727:372ecf3630cf
18 local st = require "util.stanza"; 18 local st = require "util.stanza";
19 local logger = require "util.logger"; 19 local logger = require "util.logger";
20 local log = logger.init("mod_bosh"); 20 local log = logger.init("mod_bosh");
21 local initialize_filters = require "util.filters".initialize; 21 local initialize_filters = require "util.filters".initialize;
22 local math_min = math.min; 22 local math_min = math.min;
23 local xpcall, tostring, type = xpcall, tostring, type;
24 local traceback = debug.traceback;
23 25
24 local xmlns_streams = "http://etherx.jabber.org/streams"; 26 local xmlns_streams = "http://etherx.jabber.org/streams";
25 local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams"; 27 local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams";
26 local xmlns_bosh = "http://jabber.org/protocol/httpbind"; -- (hard-coded into a literal in session.send) 28 local xmlns_bosh = "http://jabber.org/protocol/httpbind"; -- (hard-coded into a literal in session.send)
27 29
350 session.send(tostring(features)); 352 session.send(tostring(features));
351 session.notopen = nil; 353 session.notopen = nil;
352 end 354 end
353 end 355 end
354 356
357 local function handleerr(err) log("error", "Traceback[bosh]: %s", traceback(tostring(err), 2)); end
355 function stream_callbacks.handlestanza(context, stanza) 358 function stream_callbacks.handlestanza(context, stanza)
356 if context.ignore then return; end 359 if context.ignore then return; end
357 log("debug", "BOSH stanza received: %s\n", stanza:top_tag()); 360 log("debug", "BOSH stanza received: %s\n", stanza:top_tag());
358 local session = sessions[context.sid]; 361 local session = sessions[context.sid];
359 if session then 362 if session then
360 if stanza.attr.xmlns == xmlns_bosh then 363 if stanza.attr.xmlns == xmlns_bosh then
361 stanza.attr.xmlns = nil; 364 stanza.attr.xmlns = nil;
362 end 365 end
363 stanza = session.filter("stanzas/in", stanza); 366 stanza = session.filter("stanzas/in", stanza);
364 if stanza then 367 if stanza then
365 core_process_stanza(session, stanza); 368 return xpcall(function () return core_process_stanza(session, stanza) end, handleerr);
366 end 369 end
367 end 370 end
368 end 371 end
369 372
370 function stream_callbacks.streamclosed(request) 373 function stream_callbacks.streamclosed(request)