From 5e9f6df1bab8f4c6ee6d86b353f97707200860b2 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 7 Dec 2014 17:56:25 +0100 Subject: mod_bosh: Use util.async --- plugins/mod_bosh.lua | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/plugins/mod_bosh.lua b/plugins/mod_bosh.lua index ca67db73..9e8354fe 100644 --- 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 runner = require"util.async".runner; 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 +local runner_callbacks = { }; + -- Handle the 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; + 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); @@ -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 + +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()); @@ -364,9 +376,7 @@ function stream_callbacks.handlestanza(context, 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 -- cgit v1.2.3 From 4781a82cd80b53f5691f61319a138574e1cdce98 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 8 Dec 2014 15:48:36 +0100 Subject: net.http.server: Log names of the events fired --- net/http/server.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/http/server.lua b/net/http/server.lua index be870c51..581630d0 100644 --- a/net/http/server.lua +++ b/net/http/server.lua @@ -218,7 +218,7 @@ function handle_request(conn, request, finish_cb) local event = request.method.." "..host..request.path:match("[^?]*"); local payload = { request = request, response = response }; - --log("debug", "Firing event: %s", event); + log("debug", event); local result = events.fire_event(event, payload); if result ~= nil then if result ~= true then -- cgit v1.2.3 From 52642e5699f9b0cbd4e93178ea3981d9963f509b Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 8 Dec 2014 15:49:11 +0100 Subject: mod_http: Log name and base URL of HTTP apps --- plugins/mod_http.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/mod_http.lua b/plugins/mod_http.lua index 8bda1cac..76ee151b 100644 --- a/plugins/mod_http.lua +++ b/plugins/mod_http.lua @@ -84,6 +84,7 @@ function module.add_host(module) local app_name = event.item.name; local default_app_path = event.item.default_path or "/"..app_name; local app_path = get_base_path(module, app_name, default_app_path); + module:log("debug", "Serving '%s' at %s", app_name, module:http_url(app_name, app_path)); if not app_name then -- TODO: Link to docs module:log("error", "HTTP app has no 'name', add one or use module:provides('http', app)"); -- cgit v1.2.3 From f361945594fd28aced85bb500332d186f171e7a5 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 9 Dec 2014 19:36:34 +0100 Subject: mod_blocklist: Fix import --- plugins/mod_blocklist.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mod_blocklist.lua b/plugins/mod_blocklist.lua index 70bfb5fc..81bdd2c6 100644 --- a/plugins/mod_blocklist.lua +++ b/plugins/mod_blocklist.lua @@ -13,7 +13,7 @@ local user_exists = require"core.usermanager".user_exists; local is_contact_subscribed = require"core.rostermanager".is_contact_subscribed; local st = require"util.stanza"; local st_error_reply = st.error_reply; -local jid_prep, jid_split = import("jid", "prep", "split"); +local jid_prep, jid_split = import("util.jid", "prep", "split"); local host = module.host; local storage = module:open_store(); -- cgit v1.2.3 From 655e1cde09f9ffb942f698b3869b1616ef11d70c Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 11 Dec 2014 09:18:39 +0100 Subject: mod_storage_sql2, util.sql: Set character encoding on every connect --- plugins/mod_storage_sql2.lua | 2 -- util/sql.lua | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/mod_storage_sql2.lua b/plugins/mod_storage_sql2.lua index 0531c905..d5e0494f 100644 --- a/plugins/mod_storage_sql2.lua +++ b/plugins/mod_storage_sql2.lua @@ -113,8 +113,6 @@ do -- process options to get a db connection --local dburi = db2uri(params); engine = mod_sql:create_engine(params); - engine:set_encoding(); - if module:get_option("sql_manage_tables", true) then -- Automatically create table, ignore failure (table probably already exists) create_table(); diff --git a/util/sql.lua b/util/sql.lua index 5a1dda5d..453597da 100644 --- a/util/sql.lua +++ b/util/sql.lua @@ -156,6 +156,7 @@ function engine:connect() dbh:autocommit(false); -- don't commit automatically self.conn = dbh; self.prepared = {}; + self:set_encoding(); return true; end function engine:execute(sql, ...) -- cgit v1.2.3 From 72b502bed309c90247cf578caf86791ad251b949 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 13 Dec 2014 16:40:55 +0100 Subject: mod_admin_telnet: Use the session-specific print function --- plugins/mod_admin_telnet.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua index 660fb33b..0fe6d2ad 100644 --- a/plugins/mod_admin_telnet.lua +++ b/plugins/mod_admin_telnet.lua @@ -974,6 +974,7 @@ function def_env.muc:list(host) if not host_session or not host_session.modules.muc then return nil, "Please supply the address of a local MUC component"; end + local print = self.session.print; local c = 0; for name in keys(host_session.modules.muc.rooms) do print(name); -- cgit v1.2.3