Merge with 0.5

Fri, 02 Oct 2009 21:24:16 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Fri, 02 Oct 2009 21:24:16 +0100
changeset 1865
388b125b784a
parent 1862
115f274dd17f (current diff)
parent 1864
b9389286eece (diff)
child 1867
57446ab8806f

Merge with 0.5

net/server.lua file | annotate | diff | comparison | revisions
plugins/mod_bosh.lua file | annotate | diff | comparison | revisions
--- a/net/server.lua	Fri Oct 02 17:56:24 2009 +0500
+++ b/net/server.lua	Fri Oct 02 21:24:16 2009 +0100
@@ -720,7 +720,7 @@
 removeserver = function( port )
     local handler = _server[ port ]
     if not handler then
-        return nil, "no server found on port '" .. tostring( port ) "'"
+        return nil, "no server found on port '" .. tostring( port ) .. "'"
     end
     handler.close( )
     _server[ port ] = nil
--- a/plugins/mod_bosh.lua	Fri Oct 02 17:56:24 2009 +0500
+++ b/plugins/mod_bosh.lua	Fri Oct 02 21:24:16 2009 +0100
@@ -258,6 +258,7 @@
 	end
 end
 
+local dead_sessions = {};
 function on_timer()
 	-- log("debug", "Checking for requests soon to timeout...");
 	-- Identify requests timing out within the next few seconds
@@ -274,18 +275,26 @@
 	end
 	
 	now = now - 3;
+	local n_dead_sessions = 0;
 	for session, inactive_since in pairs(inactive_sessions) do
 		if session.bosh_max_inactive then
 			if now - inactive_since > session.bosh_max_inactive then
 				(session.log or log)("debug", "BOSH client inactive too long, destroying session at %d", now);
 				sessions[session.sid]  = nil;
 				inactive_sessions[session] = nil;
-				sm_destroy_session(session, "BOSH client silent for over "..session.bosh_max_inactive.." seconds");
+				n_dead_sessions = n_dead_sessions + 1;
+				dead_sessions[n_dead_sessions] = session;
 			end
 		else
 			inactive_sessions[session] = nil;
 		end
 	end
+
+	for i=1,n_dead_sessions do
+		local session = dead_sessions[i];
+		dead_sessions[i] = nil;
+		sm_destroy_session(session, "BOSH client silent for over "..session.bosh_max_inactive.." seconds");
+	end
 end
 
 local ports = module:get_option("bosh_ports") or { 5280 };

mercurial