Comparison

plugins/mod_bosh.lua @ 3039:2fef108d7eb7

mod_bosh: Remove requests from the session table using table.remove(), prevents the possibility of holes in the array.
author Matthew Wild <mwild1@gmail.com>
date Mon, 17 May 2010 11:42:53 +0100
parent 2959:62a3f824292a
child 3040:c02d0e7e088e
comparison
equal deleted inserted replaced
3027:b5beb7b15ac4 3039:2fef108d7eb7
45 function on_destroy_request(request) 45 function on_destroy_request(request)
46 waiting_requests[request] = nil; 46 waiting_requests[request] = nil;
47 local session = sessions[request.sid]; 47 local session = sessions[request.sid];
48 if session then 48 if session then
49 local requests = session.requests; 49 local requests = session.requests;
50 for i,r in pairs(requests) do 50 for i,r in ipairs(requests) do
51 if r == request then requests[i] = nil; break; end 51 if r == request then
52 t_remove(requests, i);
53 break;
54 end
52 end 55 end
53 56
54 -- If this session now has no requests open, mark it as inactive 57 -- If this session now has no requests open, mark it as inactive
55 if #requests == 0 and session.bosh_max_inactive and not inactive_sessions[session] then 58 if #requests == 0 and session.bosh_max_inactive and not inactive_sessions[session] then
56 inactive_sessions[session] = os_time(); 59 inactive_sessions[session] = os_time();