Changeset

7656:296543556065

mod_bosh: Update BOSH wait timeout logic to work despite the addition of deferred requests
author Matthew Wild <mwild1@gmail.com>
date Fri, 02 Sep 2016 23:25:11 +0100
parents 7655:132819f409dc
children 7657:252823632401
files plugins/mod_bosh.lua
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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