mod_smacks: Send <r> immediately from csi-flushing event
Using a timer serves no purpose in this case, only serves to increase
the number of write syscalls and TCP segments sent.
--- a/mod_smacks/mod_smacks.lua Mon Nov 15 15:29:02 2021 +0000
+++ b/mod_smacks/mod_smacks.lua Tue Nov 16 13:39:49 2021 +0100
@@ -650,9 +650,14 @@
end
end);
-module:hook("csi-flushing", function (event)
- if event.session.smacks then
- request_ack_if_needed(event.session, true, "csi-active", nil);
+module:hook("csi-flushing", function(event)
+ local session = event.session;
+ if session.smacks then
+ if not session.awaiting_ack and not session.hibernating and not session.destroyed then
+ session.log("debug", "Sending <r> (csi-flushing)");
+ session.awaiting_ack = true; -- The send() call may invoke this event again, so set this first
+ (session.sends2s or session.send)(st.stanza("r", { xmlns = session.smacks }))
+ end
end
end);