mod_bosh: Update BOSH wait timeout logic to work despite the addition of deferred requests
authorMatthew Wild <mwild1@gmail.com>
Fri, 02 Sep 2016 23:25:11 +0100
changeset 7659 296543556065
parent 7658 132819f409dc
child 7660 252823632401
mod_bosh: Update BOSH wait timeout logic to work despite the addition of deferred requests
plugins/mod_bosh.lua
--- a/plugins/mod_bosh.lua	Fri Sep 02 23:24:40 2016 +0100
+++ b/plugins/mod_bosh.lua	Fri Sep 02 23:25:11 2016 +0100
@@ -197,9 +197,6 @@
 		if not response.finished then
 			-- 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
-				session.bosh_wait_timer = module:add_timer(session.bosh_wait, after_bosh_wait, request, session)
-			end
 		end
 
 		if session.bosh_terminate then
@@ -207,6 +204,10 @@
 			session:close();
 			return nil;
 		else
+			if session.bosh_wait and #session.requests > 0 then
+				session.bosh_wait_timer = module:add_timer(session.bosh_wait, after_bosh_wait, session.requests[1], session)
+			end
+
 			return true; -- Inform http server we shall reply later
 		end
 	elseif response.finished then