# HG changeset patch
# User Matthew Wild <mwild1@gmail.com>
# Date 1327280217 0
# Node ID e6e5c76ff00916736a808ca5ed39badb4ecc153a
# Parent  d9d777e97e8f38232abf15c4883c1b97e29b7e12
sessionmanager, mod_c2s: Move timeout logic to mod_c2s

diff -r d9d777e97e8f -r e6e5c76ff009 core/sessionmanager.lua
--- a/core/sessionmanager.lua	Mon Jan 23 00:11:01 2012 +0000
+++ b/core/sessionmanager.lua	Mon Jan 23 00:56:57 2012 +0000
@@ -28,8 +28,6 @@
 
 local st = require "util.stanza";
 
-local c2s_timeout = config_get("*", "core", "c2s_timeout");
-
 local newproxy = newproxy;
 local getmetatable = getmetatable;
 
@@ -62,14 +60,6 @@
 	session.ip = conn:ip();
 	local conn_name = "c2s"..tostring(conn):match("[a-f0-9]+$");
 	session.log = logger.init(conn_name);
-	
-	if c2s_timeout then
-		add_task(c2s_timeout, function ()
-			if session.type == "c2s_unauthed" then
-				session:close("connection-timeout");
-			end
-		end);
-	end
 		
 	return session;
 end
diff -r d9d777e97e8f -r e6e5c76ff009 plugins/mod_c2s.lua
--- a/plugins/mod_c2s.lua	Mon Jan 23 00:11:01 2012 +0000
+++ b/plugins/mod_c2s.lua	Mon Jan 23 00:56:57 2012 +0000
@@ -8,6 +8,7 @@
 
 module:set_global();
 
+local add_task = require "util.timer".add_task;
 local new_xmpp_stream = require "util.xmppstream".new;
 local nameprep = require "util.encodings".stringprep.nameprep;
 local portmanager = require "core.portmanager";
@@ -24,6 +25,7 @@
 
 local log = module._log;
 
+local c2s_timeout = module:get_option_number("c2s_timeout");
 local opt_keepalives = module:get_option_boolean("tcp_keepalives", false);
 
 local sessions = module:shared("sessions");
@@ -186,6 +188,15 @@
 		end
 	end
 
+	
+	if c2s_timeout then
+		add_task(c2s_timeout, function ()
+			if session.type == "c2s_unauthed" then
+				session:close("connection-timeout");
+			end
+		end);
+	end
+
 	session.dispatch_stanza = stream_callbacks.handlestanza;
 end