Comparison

mod_smacks/mod_smacks.lua @ 478:db0f065c4e09

mod_smacks: Don't destroy a session that binds the same resource as a hibernating smacks session (thanks xnyhps for tracking down the problem, though I've used a different fix)
author Matthew Wild <mwild1@gmail.com>
date Sat, 19 Nov 2011 22:39:02 +0000
parent 345:445178d15b51
child 576:44b69c3d5351
comparison
equal deleted inserted replaced
477:bbe4df968099 478:db0f065c4e09
165 handle_unacked_stanzas(session); 165 handle_unacked_stanzas(session);
166 end 166 end
167 else 167 else
168 local hibernate_time = os_time(); -- Track the time we went into hibernation 168 local hibernate_time = os_time(); -- Track the time we went into hibernation
169 session.hibernating = hibernate_time; 169 session.hibernating = hibernate_time;
170 local resumption_token = session.resumption_token;
170 timer.add_task(resume_timeout, function () 171 timer.add_task(resume_timeout, function ()
172 -- We need to check the current resumption token for this resource
173 -- matches the smacks session this timer is for in case it changed
174 -- (for example, the client may have bound a new resource and
175 -- started a new smacks session, or not be using smacks)
176 local curr_session = hosts[session.host].sessions[session.username].sessions[session.resource];
177 if curr_session.resumption_token == resumption_token
171 -- Check the hibernate time still matches what we think it is, 178 -- Check the hibernate time still matches what we think it is,
172 -- otherwise the session resumed and re-hibernated. 179 -- otherwise the session resumed and re-hibernated.
173 if session.hibernating == hibernate_time then 180 and session.hibernating == hibernate_time then
174 session_registry[session.resumption_token] = nil; 181 session_registry[session.resumption_token] = nil;
175 session.resumption_token = nil; 182 session.resumption_token = nil;
176 -- This recursion back into our destroy handler is to 183 -- This recursion back into our destroy handler is to
177 -- make sure we still handle any queued stanzas 184 -- make sure we still handle any queued stanzas
178 sessionmanager.destroy_session(session); 185 sessionmanager.destroy_session(session);