diff options
author | Waqas Hussain <waqas20@gmail.com> | 2008-10-23 21:51:00 +0500 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2008-10-23 21:51:00 +0500 |
commit | 98a409f8b417a5b0600b7b60a5ed6598bfc0dd20 (patch) | |
tree | 9bf6c746e90f9a5a6a07c1a046959f2654690729 /core/sessionmanager.lua | |
parent | aa5e75a22e06ca2bf0ee70370ce4e430893ac807 (diff) | |
parent | 3286f0609f034a3b9814a3d7df4151008554f992 (diff) | |
download | prosody-98a409f8b417a5b0600b7b60a5ed6598bfc0dd20.tar.gz prosody-98a409f8b417a5b0600b7b60a5ed6598bfc0dd20.zip |
Merged from Matthew
Diffstat (limited to 'core/sessionmanager.lua')
-rw-r--r-- | core/sessionmanager.lua | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index 8bdb93d0..19614311 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -19,30 +19,27 @@ 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; end - local nomore = true; - for res, ssn in pairs(hosts[session.host].sessions[session.username]) do - nomore = false; - end - if nomore then + if not next(hosts[session.host].sessions[session.username], nil) then hosts[session.host].sessions[session.username] = nil; end end @@ -53,11 +50,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) |