From 5f625f405e737ff7841afd8dac95f5b6bf70f804 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 28 Dec 2012 14:32:22 +0100 Subject: mod_admin_telnet: Stop processing lines when session is closed --- plugins/mod_admin_telnet.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'plugins') diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua index 12ab2355..e1b90684 100644 --- a/plugins/mod_admin_telnet.lua +++ b/plugins/mod_admin_telnet.lua @@ -149,6 +149,7 @@ function console_listener.onincoming(conn, data) end for line in data:gmatch("[^\n]*[\n\004]") do + if session.closed then return end console:process_line(session, line); session.send(string.char(0)); end @@ -168,6 +169,7 @@ end function commands.bye(session) session.print("See you! :)"); + session.closed = true; session.disconnect(); end commands.quit, commands.exit = commands.bye, commands.bye; -- cgit v1.2.3 From 4cb252484ceeac4c8ae6ae2896e58816f83266e9 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 28 Dec 2012 14:33:47 +0100 Subject: prosody, mod_c2s, mod_s2s: Move closing of c2s and s2s sessions to respective plugins --- plugins/mod_c2s.lua | 9 +++++++++ plugins/mod_s2s/mod_s2s.lua | 9 +++++++++ 2 files changed, 18 insertions(+) (limited to 'plugins') diff --git a/plugins/mod_c2s.lua b/plugins/mod_c2s.lua index 72085113..89d678ca 100644 --- a/plugins/mod_c2s.lua +++ b/plugins/mod_c2s.lua @@ -265,6 +265,15 @@ function listener.associate_session(conn, session) sessions[conn] = session; end +module:hook("server-stopping", function(event) + local reason = event.reason; + for _, session in pairs(sessions) do + session:close{ condition = "system-shutdown", text = reason }; + end +end, 1000); + + + module:provides("net", { name = "c2s"; listener = listener; diff --git a/plugins/mod_s2s/mod_s2s.lua b/plugins/mod_s2s/mod_s2s.lua index 788a64af..ad628a9b 100644 --- a/plugins/mod_s2s/mod_s2s.lua +++ b/plugins/mod_s2s/mod_s2s.lua @@ -506,6 +506,15 @@ end s2sout.set_listener(listener); +module:hook("server-stopping", function(event) + local reason = event.reason; + for _, session in pairs(sessions) do + session:close{ condition = "system-shutdown", text = reason }; + end +end,500); + + + module:provides("net", { name = "s2s"; listener = listener; -- cgit v1.2.3