Comparison

mod_smacks/mod_smacks.lua @ 1539:05fa54404012

mod_smacks: Send ack requests by serializing and concatenating them to outgoing stanzas, using a timer might cause high CPU usage
author Kim Alvefur <zash@zash.se>
date Tue, 28 Oct 2014 22:26:41 +0100
parent 1531:7d86fc477993
child 1597:dc0cf2ba0e1a
comparison
equal deleted inserted replaced
1538:57bb2497fadc 1539:05fa54404012
72 session.log("debug", "#queue = %d", #queue); 72 session.log("debug", "#queue = %d", #queue);
73 if session.hibernating then 73 if session.hibernating then
74 session.log("debug", "hibernating, stanza queued"); 74 session.log("debug", "hibernating, stanza queued");
75 return ""; -- Hack to make session.send() not return nil 75 return ""; -- Hack to make session.send() not return nil
76 end 76 end
77 if #queue > max_unacked_stanzas then 77 if #queue > max_unacked_stanzas and not session.awaiting_ack then
78 module:add_timer(0, function () 78 session.awaiting_ack = true;
79 if not session.awaiting_ack then 79 return tostring(stanza)..tostring(st.stanza("r", { xmlns = session.smacks }));
80 session.awaiting_ack = true;
81 (session.sends2s or session.send)(st.stanza("r", { xmlns = session.smacks }));
82 end
83 end);
84 end 80 end
85 end 81 end
86 return stanza; 82 return stanza;
87 end 83 end
88 84