Comparison

mod_smacks/mod_smacks.lua @ 1405:26a2092e289f

mod_smacks: Log things attached to sessions instead of the module
author Kim Alvefur <zash@zash.se>
date Wed, 07 May 2014 14:17:03 +0200
parent 1343:7dbde05b48a9
child 1406:7d76dd2310ef
comparison
equal deleted inserted replaced
1404:99cb06b31ae8 1405:26a2092e289f
192 -- Remove handled stanzas from outgoing_stanza_queue 192 -- Remove handled stanzas from outgoing_stanza_queue
193 --log("debug", "ACK: h=%s, last=%s", stanza.attr.h or "", origin.last_acknowledged_stanza or ""); 193 --log("debug", "ACK: h=%s, last=%s", stanza.attr.h or "", origin.last_acknowledged_stanza or "");
194 local handled_stanza_count = tonumber(stanza.attr.h)-origin.last_acknowledged_stanza; 194 local handled_stanza_count = tonumber(stanza.attr.h)-origin.last_acknowledged_stanza;
195 local queue = origin.outgoing_stanza_queue; 195 local queue = origin.outgoing_stanza_queue;
196 if handled_stanza_count > #queue then 196 if handled_stanza_count > #queue then
197 module:log("warn", "The client says it handled %d new stanzas, but we only sent %d :)", 197 session.log("warn", "The client says it handled %d new stanzas, but we only sent %d :)",
198 handled_stanza_count, #queue); 198 handled_stanza_count, #queue);
199 module:log("debug", "Client h: %d, our h: %d", tonumber(stanza.attr.h), origin.last_acknowledged_stanza); 199 session.log("debug", "Client h: %d, our h: %d", tonumber(stanza.attr.h), origin.last_acknowledged_stanza);
200 for i=1,#queue do 200 for i=1,#queue do
201 module:log("debug", "Q item %d: %s", i, tostring(queue[i])); 201 session.log("debug", "Q item %d: %s", i, tostring(queue[i]));
202 end 202 end
203 end 203 end
204 for i=1,math_min(handled_stanza_count,#queue) do 204 for i=1,math_min(handled_stanza_count,#queue) do
205 t_remove(origin.outgoing_stanza_queue, 1); 205 t_remove(origin.outgoing_stanza_queue, 1);
206 end 206 end
236 local session, err = event.session, event.error; 236 local session, err = event.session, event.error;
237 if session.smacks then 237 if session.smacks then
238 if not session.resumption_token then 238 if not session.resumption_token then
239 local queue = session.outgoing_stanza_queue; 239 local queue = session.outgoing_stanza_queue;
240 if #queue > 0 then 240 if #queue > 0 then
241 module:log("warn", "Destroying session with %d unacked stanzas", #queue); 241 session.log("warn", "Destroying session with %d unacked stanzas", #queue);
242 handle_unacked_stanzas(session); 242 handle_unacked_stanzas(session);
243 end 243 end
244 else 244 else
245 session.log("debug", "mod_smacks hibernating session for up to %d seconds", resume_timeout); 245 session.log("debug", "mod_smacks hibernating session for up to %d seconds", resume_timeout);
246 local hibernate_time = os_time(); -- Track the time we went into hibernation 246 local hibernate_time = os_time(); -- Track the time we went into hibernation