diff options
author | Matthew Wild <mwild1@gmail.com> | 2008-10-23 16:07:40 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2008-10-23 16:07:40 +0100 |
commit | ff0fe0544adcca56ea47acdfda9c76dfe990ee61 (patch) | |
tree | ce8cada7737fcb5d933defe81f1e0d2ff301da01 /core | |
parent | b13393bcd9dc1387db476afd2c764d946097b549 (diff) | |
download | prosody-ff0fe0544adcca56ea47acdfda9c76dfe990ee61.tar.gz prosody-ff0fe0544adcca56ea47acdfda9c76dfe990ee61.zip |
Fix for not destroying sessions when connection closed.
Diffstat (limited to 'core')
-rw-r--r-- | core/sessionmanager.lua | 14 |
1 files changed, 5 insertions, 9 deletions
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) |