Comparison

plugins/mod_bosh.lua @ 4000:ca91d6e1d802

mod_bosh: Fix for miscalculating inactivity, causing disconnects under a steady stream of traffic
author Matthew Wild <mwild1@gmail.com>
date Tue, 04 Jan 2011 21:38:14 +0000
parent 3725:926ece7d0e67
child 4102:9df4e61c260b
comparison
equal deleted inserted replaced
3999:58c0de7c6da0 4000:ca91d6e1d802
123 -- the body are processed in this next line before it returns. 123 -- the body are processed in this next line before it returns.
124 stream:feed(body); 124 stream:feed(body);
125 125
126 local session = sessions[request.sid]; 126 local session = sessions[request.sid];
127 if session then 127 if session then
128 -- Session was marked as inactive, since we have
129 -- a request open now, unmark it
130 if inactive_sessions[session] then
131 inactive_sessions[session] = nil;
132 end
133
128 local r = session.requests; 134 local r = session.requests;
129 log("debug", "Session %s has %d out of %d requests open", request.sid, #r, session.bosh_hold); 135 log("debug", "Session %s has %d out of %d requests open", request.sid, #r, session.bosh_hold);
130 log("debug", "and there are %d things in the send_buffer", #session.send_buffer); 136 log("debug", "and there are %d things in the send_buffer", #session.send_buffer);
131 if #r > session.bosh_hold then 137 if #r > session.bosh_hold then
132 -- We are holding too many requests, send what's in the buffer, 138 -- We are holding too many requests, send what's in the buffer,
151 -- We're keeping this request open, to respond later 157 -- We're keeping this request open, to respond later
152 log("debug", "Have nothing to say, so leaving request unanswered for now"); 158 log("debug", "Have nothing to say, so leaving request unanswered for now");
153 if session.bosh_wait then 159 if session.bosh_wait then
154 request.reply_before = os_time() + session.bosh_wait; 160 request.reply_before = os_time() + session.bosh_wait;
155 waiting_requests[request] = true; 161 waiting_requests[request] = true;
156 end
157 if inactive_sessions[session] then
158 -- Session was marked as inactive, since we have
159 -- a request open now, unmark it
160 inactive_sessions[session] = nil;
161 end 162 end
162 end 163 end
163 164
164 return true; -- Inform httpserver we shall reply later 165 return true; -- Inform httpserver we shall reply later
165 end 166 end