Comparison

mod_smacks/mod_smacks.lua @ 1406:7d76dd2310ef

mod_smacks: Add more debug logging
author Kim Alvefur <zash@zash.se>
date Wed, 07 May 2014 14:19:44 +0200
parent 1405:26a2092e289f
child 1407:b631c8a8b9e7
comparison
equal deleted inserted replaced
1405:26a2092e289f 1406:7d76dd2310ef
89 if cached_stanza and cached_stanza:get_child("delay", xmlns_delay) == nil then 89 if cached_stanza and cached_stanza:get_child("delay", xmlns_delay) == nil then
90 cached_stanza = cached_stanza:tag("delay", { xmlns = xmlns_delay, from = session.host, stamp = datetime.datetime()}); 90 cached_stanza = cached_stanza:tag("delay", { xmlns = xmlns_delay, from = session.host, stamp = datetime.datetime()});
91 end 91 end
92 92
93 queue[#queue+1] = cached_stanza; 93 queue[#queue+1] = cached_stanza;
94 session.log("debug", "#queue = %d", #queue);
94 end 95 end
95 if session.hibernating then 96 if session.hibernating then
97 session.log("debug", "hibernating, stanza queued")
96 -- The session is hibernating, no point in sending the stanza 98 -- The session is hibernating, no point in sending the stanza
97 -- over a dead connection. It will be delivered upon resumption. 99 -- over a dead connection. It will be delivered upon resumption.
98 return true; 100 return true;
99 end 101 end
100 local ok, err = _send(stanza); 102 local ok, err = _send(stanza);
202 end 204 end
203 end 205 end
204 for i=1,math_min(handled_stanza_count,#queue) do 206 for i=1,math_min(handled_stanza_count,#queue) do
205 t_remove(origin.outgoing_stanza_queue, 1); 207 t_remove(origin.outgoing_stanza_queue, 1);
206 end 208 end
209 origin.log("debug", "#queue = %d", #queue);
207 origin.last_acknowledged_stanza = origin.last_acknowledged_stanza + handled_stanza_count; 210 origin.last_acknowledged_stanza = origin.last_acknowledged_stanza + handled_stanza_count;
208 return true; 211 return true;
209 end 212 end
210 module:hook_stanza(xmlns_sm2, "a", handle_a); 213 module:hook_stanza(xmlns_sm2, "a", handle_a);
211 module:hook_stanza(xmlns_sm3, "a", handle_a); 214 module:hook_stanza(xmlns_sm3, "a", handle_a);
331 h = stanza.attr.h })); 334 h = stanza.attr.h }));
332 335
333 -- Ok, we need to re-send any stanzas that the client didn't see 336 -- Ok, we need to re-send any stanzas that the client didn't see
334 -- ...they are what is now left in the outgoing stanza queue 337 -- ...they are what is now left in the outgoing stanza queue
335 local queue = original_session.outgoing_stanza_queue; 338 local queue = original_session.outgoing_stanza_queue;
339 session.log("debug", "#queue = %d", #queue);
336 for i=1,#queue do 340 for i=1,#queue do
337 session.send(queue[i]); 341 session.send(queue[i]);
338 end 342 end
343 session.log("debug", "#queue = %d -- after send", #queue);
339 else 344 else
340 module:log("warn", "Client %s@%s[%s] tried to resume stream for %s@%s[%s]", 345 module:log("warn", "Client %s@%s[%s] tried to resume stream for %s@%s[%s]",
341 session.username or "?", session.host or "?", session.type, 346 session.username or "?", session.host or "?", session.type,
342 original_session.username or "?", original_session.host or "?", original_session.type); 347 original_session.username or "?", original_session.host or "?", original_session.type);
343 session.send(st.stanza("failed", { xmlns = xmlns_sm }) 348 session.send(st.stanza("failed", { xmlns = xmlns_sm })