diff mod_cloud_notify/mod_cloud_notify.lua @ 4412:e5493a10c4d1

mod_cloud_notify: use stanza from mod_smacks to behave O(1) This uses the provided stanza in the ack-delayed smacks event to trigger push for this stanza only rather than iterating through the whole smacks queue to find the first unpushed stanza.
author tmolitor <thilo@eightysoft.de>
date Sat, 30 Jan 2021 07:17:33 +0100
parents 33f82988d7a9
children 157fa4e535b0
line wrap: on
line diff
--- a/mod_cloud_notify/mod_cloud_notify.lua	Sat Jan 30 01:10:06 2021 +0100
+++ b/mod_cloud_notify/mod_cloud_notify.lua	Sat Jan 30 07:17:33 2021 +0100
@@ -476,7 +476,10 @@
 local function restore_session(event)
 	local session = event.resumed;
 	if session then		-- older smacks module versions send only the "intermediate" session in event.session and no session.resumed one
-		if session.awaiting_push_timer then session.awaiting_push_timer:stop(); end
+		if session.awaiting_push_timer then
+			session.awaiting_push_timer:stop();
+			session.awaiting_push_timer = nil;
+		end
 		session.first_hibernated_push = nil;
 	end
 end
@@ -485,7 +488,9 @@
 local function ack_delayed(event)
 	local session = event.origin;
 	local queue = event.queue;
+	local stanza = event.stanza;
 	if not session.push_identifier then return; end
+	if stanza then process_stanza(session, stanza); return; end		-- don't iterate through smacks queue if we know which stanza triggered this
 	for i=1, #queue do
 		local stanza = queue[i];
 		-- process unacked stanzas (handle_notify_request() will only send push requests for new stanzas)