Comparison

mod_component_roundrobin/mod_component_roundrobin.lua @ 1254:b0136968bef1

mod_component_roundrobin: Make sure we don’t try to use destroyed sessions.
author Waqas Hussain <waqas20@gmail.com>
date Thu, 19 Dec 2013 08:54:33 -0500
parent 1253:19cf607111fb
child 1255:3c35283b6780
comparison
equal deleted inserted replaced
1253:19cf607111fb 1254:b0136968bef1
19 19
20 local log = module._log; 20 local log = module._log;
21 21
22 local sessions = {}; 22 local sessions = {};
23 23
24 local last_session;
24 local function on_destroy(session, err) 25 local function on_destroy(session, err)
25 if sessions[session] then 26 if sessions[session] then
27 if last_session == session then last_session = nil; end
26 sessions[session] = nil; 28 sessions[session] = nil;
27 session.on_destroy = nil; 29 session.on_destroy = nil;
28 end 30 end
29 end 31 end
30 32
31 local last_session;
32 local function handle_stanza(event) 33 local function handle_stanza(event)
33 local stanza = event.stanza; 34 local stanza = event.stanza;
34 if next(sessions) then 35 if next(sessions) then
35 stanza.attr.xmlns = nil; 36 stanza.attr.xmlns = nil;
36 last_session = next(sessions, last_session) or next(sessions); 37 last_session = next(sessions, last_session) or next(sessions);