Changeset

163:3fec9b512d4e

Clean up session when s2s connections are disconnected
author Matthew Wild <mwild1@gmail.com>
date Fri, 24 Oct 2008 18:13:54 +0100 (2008-10-24)
parents 162:b1099bdd2724
children 164:8dc1faa5b1df
files net/xmppserver_listener.lua
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/net/xmppserver_listener.lua	Fri Oct 24 15:33:38 2008 +0100
+++ b/net/xmppserver_listener.lua	Fri Oct 24 18:13:54 2008 +0100
@@ -5,6 +5,7 @@
 local sm_new_session = require "core.sessionmanager".new_session;
 local s2s_new_incoming = require "core.s2smanager".new_incoming;
 local s2s_streamopened = require "core.s2smanager".streamopened;
+local s2s_destroy_session = require "core.s2smanager".destroy_session;
 
 local connlisteners_register = require "net.connlisteners".register;
 
@@ -70,6 +71,13 @@
 end
 	
 function xmppserver.disconnect(conn)
+	local session = sessions[conn];
+	if session then
+		s2s_destroy_session(session);
+		sessions[conn]  = nil;
+		session = nil;
+		collectgarbage("collect");
+	end
 end
 
 function xmppserver.register_outgoing(conn, session)