# HG changeset patch # User Kim Alvefur # Date 1458215244 -3600 # Node ID 9434a220e549a04595a312e7c0d31efc9e0c21c2 # Parent 32754b15b28a582b73a1a242ff40a3d9bdf75dd6 mod_c2s: Remove use of util.async diff -r 32754b15b28a -r 9434a220e549 core/sessionmanager.lua --- a/core/sessionmanager.lua Thu Mar 17 12:46:52 2016 +0100 +++ b/core/sessionmanager.lua Thu Mar 17 12:47:24 2016 +0100 @@ -72,7 +72,6 @@ function session.send(data) log("debug", "Discarding data sent to resting session: %s", tostring(data)); return false; end function session.data(data) log("debug", "Discarding data received from resting session: %s", tostring(data)); end - session.thread = { run = function (_, data) return session.data(data) end }; return setmetatable(session, resting_session); end diff -r 32754b15b28a -r 9434a220e549 plugins/mod_c2s.lua --- a/plugins/mod_c2s.lua Thu Mar 17 12:46:52 2016 +0100 +++ b/plugins/mod_c2s.lua Thu Mar 17 12:47:24 2016 +0100 @@ -15,10 +15,9 @@ local st = require "util.stanza"; local sm_new_session, sm_destroy_session = sessionmanager.new_session, sessionmanager.destroy_session; local uuid_generate = require "util.uuid".generate; -local runner = require "util.async".runner; local xpcall, tostring, type = xpcall, tostring, type; -local t_insert, t_remove = table.insert, table.remove; +local traceback = debug.traceback; local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams"; @@ -36,7 +35,6 @@ local stream_callbacks = { default_ns = "jabber:client" }; local listener = {}; -local runner_callbacks = {}; --- Stream events handlers local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'}; @@ -123,9 +121,12 @@ end 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); - session.thread:run(stanza); + if stanza then + return xpcall(function () return core_process_stanza(session, stanza) end, handleerr); + end end --- Session methods @@ -191,18 +192,6 @@ end end, 200); -function runner_callbacks:ready() - self.data.conn:resume(); -end - -function runner_callbacks:waiting() - self.data.conn:pause(); -end - -function runner_callbacks:error(err) - (self.data.log or log)("error", "Traceback[c2s]: %s", err); -end - --- Port listener function listener.onconnect(conn) measure_connections(1); @@ -240,10 +229,6 @@ session.stream:reset(); end - session.thread = runner(function (stanza) - core_process_stanza(session, stanza); - end, runner_callbacks, session); - local filter = session.filter; function session.data(data) -- Parse the data, which will store stanzas in session.pending_stanzas