Changeset

3085:1ea6861b533f

mod_cloud_notify: Don't change table while iterating it
author tmolitor <thilo@eightysoft.de>
date Sat, 02 Jun 2018 02:58:45 +0200
parents 3084:5b4e7db5943c
children 3086:3e91eb1bdd84
files mod_cloud_notify/mod_cloud_notify.lua
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_cloud_notify/mod_cloud_notify.lua	Fri Jun 01 22:45:41 2018 +0200
+++ b/mod_cloud_notify/mod_cloud_notify.lua	Sat Jun 02 02:58:45 2018 +0200
@@ -138,6 +138,7 @@
 	if node == nil then return false; end		-- unknown stanza? Ignore for now!
 	local from = stanza.attr.from;
 	local user_push_services = push_store:get(node);
+	local changed = false;
 	
 	for push_identifier, _ in pairs(user_push_services) do
 		local stanza_id = hashes.sha256(push_identifier, true);
@@ -159,7 +160,8 @@
 						end
 					end
 					-- save changed global config
-					push_store:set_identifier(node, push_identifier, nil);
+					changed = true;
+					user_push_services[push_identifier] = nil
 					push_errors[push_identifier] = nil;
 					-- unhook iq handlers for this identifier (if possible)
 					if module.unhook then
@@ -174,6 +176,9 @@
 			end
 		end
 	end
+	if changed then
+		push_store:set(node, user_push_services);
+	end
 	return true;
 end