projects
/
prosody.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
mod_blocklist: Use util.cache to manage how many users blocklists are kept in memory
[prosody.git]
/
plugins
/
mod_bosh.lua
diff --git
a/plugins/mod_bosh.lua
b/plugins/mod_bosh.lua
index ca67db738c6c7f644862363e45e9741375f3d3c4..9e8354fec893ae7711806f1b6e1044006c34f75c 100644
(file)
--- a/
plugins/mod_bosh.lua
+++ b/
plugins/mod_bosh.lua
@@
-22,6
+22,7
@@
local initialize_filters = require "util.filters".initialize;
local math_min = math.min;
local xpcall, tostring, type = xpcall, tostring, type;
local traceback = debug.traceback;
local math_min = math.min;
local xpcall, tostring, type = xpcall, tostring, type;
local traceback = debug.traceback;
+local runner = require"util.async".runner;
local xmlns_streams = "http://etherx.jabber.org/streams";
local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams";
local xmlns_streams = "http://etherx.jabber.org/streams";
local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams";
@@
-228,6
+229,8
@@
local function bosh_close_stream(session, reason)
sm_destroy_session(session);
end
sm_destroy_session(session);
end
+local runner_callbacks = { };
+
-- Handle the <body> tag in the request payload.
function stream_callbacks.streamopened(context, attr)
local request, response = context.request, context.response;
-- Handle the <body> tag in the request payload.
function stream_callbacks.streamopened(context, attr)
local request, response = context.request, context.response;
@@
-260,6
+263,10
@@
function stream_callbacks.streamopened(context, attr)
};
sessions[sid] = session;
};
sessions[sid] = session;
+ session.thread = runner(function (stanza)
+ session:dispatch_stanza(stanza);
+ end, runner_callbacks, session);
+
local filter = initialize_filters(session);
session.log("debug", "BOSH session created for request from %s", session.ip);
local filter = initialize_filters(session);
session.log("debug", "BOSH session created for request from %s", session.ip);
@@
-355,6
+362,11
@@
function stream_callbacks.streamopened(context, attr)
end
local function handleerr(err) log("error", "Traceback[bosh]: %s", traceback(tostring(err), 2)); end
end
local function handleerr(err) log("error", "Traceback[bosh]: %s", traceback(tostring(err), 2)); end
+
+function runner_callbacks:error(err)
+ return handleerr(err);
+end
+
function stream_callbacks.handlestanza(context, stanza)
if context.ignore then return; end
log("debug", "BOSH stanza received: %s\n", stanza:top_tag());
function stream_callbacks.handlestanza(context, stanza)
if context.ignore then return; end
log("debug", "BOSH stanza received: %s\n", stanza:top_tag());
@@
-364,9
+376,7
@@
function stream_callbacks.handlestanza(context, stanza)
stanza.attr.xmlns = nil;
end
stanza = session.filter("stanzas/in", stanza);
stanza.attr.xmlns = nil;
end
stanza = session.filter("stanzas/in", stanza);
- if stanza then
- return xpcall(function () return core_process_stanza(session, stanza) end, handleerr);
- end
+ session.thread:run(stanza);
end
end
end
end