# HG changeset patch # User tmolitor # Date 1527901125 -7200 # Node ID 1ea6861b533fcd86169449e08ec2c12612a966e3 # Parent 5b4e7db5943c25727107d32a20090d58e187eb46 mod_cloud_notify: Don't change table while iterating it diff -r 5b4e7db5943c -r 1ea6861b533f mod_cloud_notify/mod_cloud_notify.lua --- 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