From b13393bcd9dc1387db476afd2c764d946097b549 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 23 Oct 2008 14:39:42 +0100 Subject: No s2s yet :) --- core/stanza_router.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core') diff --git a/core/stanza_router.lua b/core/stanza_router.lua index 1b1db61e..2203f351 100644 --- a/core/stanza_router.lua +++ b/core/stanza_router.lua @@ -9,7 +9,7 @@ local log = require "util.logger".init("stanzarouter") local st = require "util.stanza"; local send = require "core.sessionmanager".send_to_session; -local send_s2s = require "core.s2smanager".send_to_host; +-- local send_s2s = require "core.s2smanager".send_to_host; local user_exists = require "core.usermanager".user_exists; local jid_split = require "util.jid".split; -- cgit v1.2.3 From ff0fe0544adcca56ea47acdfda9c76dfe990ee61 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 23 Oct 2008 16:07:40 +0100 Subject: Fix for not destroying sessions when connection closed. --- core/sessionmanager.lua | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'core') diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index 8bdb93d0..b012ac6c 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -19,21 +19,22 @@ local getmetatable = getmetatable; module "sessionmanager" +local open_sessions = 0; + function new_session(conn) local session = { conn = conn, priority = 0, type = "c2s_unauthed" }; if true then session.trace = newproxy(true); - getmetatable(session.trace).__gc = function () print("Session got collected") end; + getmetatable(session.trace).__gc = function () open_sessions = open_sessions - 1; print("Session got collected, now "..open_sessions.." sessions are allocated") end; end + open_sessions = open_sessions + 1; local w = conn.write; session.send = function (t) w(tostring(t)); end return session; end function destroy_session(session) - if not (session and session.disconnect) then return; end - log("debug", "Destroying session..."); - session.disconnect(); + session.log("info", "Destroying session"); if session.username then if session.resource then hosts[session.host].sessions[session.username].sessions[session.resource] = nil; @@ -53,11 +54,6 @@ function destroy_session(session) session[k] = nil; end end - collectgarbage("collect"); - collectgarbage("collect"); - collectgarbage("collect"); - collectgarbage("collect"); - collectgarbage("collect"); end function send_to_session(session, data) -- cgit v1.2.3 From 9e6c3919af199834aa3f5abb2d7988d38e6f09ed Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 23 Oct 2008 17:27:41 +0100 Subject: faster checking for other sessions --- core/sessionmanager.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'core') diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index b012ac6c..a4fb8a87 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -42,6 +42,7 @@ function destroy_session(session) local nomore = true; for res, ssn in pairs(hosts[session.host].sessions[session.username]) do nomore = false; + break; end if nomore then hosts[session.host].sessions[session.username] = nil; -- cgit v1.2.3 From 3286f0609f034a3b9814a3d7df4151008554f992 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 23 Oct 2008 17:34:10 +0100 Subject: even faster checking for other sessions... thank you waqas :) --- core/sessionmanager.lua | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'core') diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index a4fb8a87..19614311 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -39,12 +39,7 @@ function destroy_session(session) if session.resource then hosts[session.host].sessions[session.username].sessions[session.resource] = nil; end - local nomore = true; - for res, ssn in pairs(hosts[session.host].sessions[session.username]) do - nomore = false; - break; - end - if nomore then + if not next(hosts[session.host].sessions[session.username], nil) then hosts[session.host].sessions[session.username] = nil; end end -- cgit v1.2.3