mod_bosh: Optimisation, store reply_before value as waiting_requests value (saves a lookup)
authorMatthew Wild <mwild1@gmail.com>
Wed, 25 Apr 2012 19:57:46 +0100
changeset 4690 55f690fdc915
parent 4689 e8c357259993
child 4691 a164fc7057ae
mod_bosh: Optimisation, store reply_before value as waiting_requests value (saves a lookup)
plugins/mod_bosh.lua
--- a/plugins/mod_bosh.lua	Wed Apr 25 15:02:27 2012 +0100
+++ b/plugins/mod_bosh.lua	Wed Apr 25 19:57:46 2012 +0100
@@ -165,8 +165,7 @@
 			-- We're keeping this request open, to respond later
 			log("debug", "Have nothing to say, so leaving request unanswered for now");
 			if session.bosh_wait then
-				request.reply_before = os_time() + session.bosh_wait;
-				waiting_requests[request] = true;
+				waiting_requests[request] = os_time() + session.bosh_wait;
 			end
 		end
 		
@@ -399,8 +398,8 @@
 	-- log("debug", "Checking for requests soon to timeout...");
 	-- Identify requests timing out within the next few seconds
 	local now = os_time() + 3;
-	for request in pairs(waiting_requests) do
-		if request.reply_before <= now then
+	for request, reply_before in pairs(waiting_requests) do
+		if reply_before <= now then
 			log("debug", "%s was soon to timeout, sending empty response", request.id);
 			-- Send empty response to let the
 			-- client know we're still here