changeset 623:c1f3958695ea

mod_smacks: If a resumed session still has a connection open, close that connection before resuming
author Matthew Wild <mwild1@gmail.com>
date Sat, 17 Mar 2012 15:53:45 +0000 (2012-03-17)
parents ce39df945de1
children 55a9d3c2f73b
files mod_smacks/mod_smacks.lua
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mod_smacks/mod_smacks.lua	Mon Mar 05 16:53:30 2012 +0000
+++ b/mod_smacks/mod_smacks.lua	Sat Mar 17 15:53:45 2012 +0000
@@ -252,6 +252,12 @@
 	and session.host == original_session.host then
 		session.log("debug", "mod_smacks resuming existing session...");
 		-- TODO: All this should move to sessionmanager (e.g. session:replace(new_session))
+		if original_session.conn then
+			session.log("debug", "mod_smacks closing an old connection for this session");
+			local conn = original_session.conn;
+			require "net.connlisteners".get("xmppclient").associate_session(conn, nil);
+			conn:close();
+		end
 		original_session.ip = session.ip;
 		original_session.conn = session.conn;
 		original_session.send = session.send;