changeset 2039:464edd03099a

mod_mam: Add a bit of randomness to cleanup intervals to keep some time between multiple instances
author Kim Alvefur <zash@zash.se>
date Tue, 02 Feb 2016 16:26:21 +0100
parents a85b5c3791dc
children 459e1878d23c
files mod_mam/mod_mam.lua
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mod_mam/mod_mam.lua	Tue Feb 02 16:22:46 2016 +0100
+++ b/mod_mam/mod_mam.lua	Tue Feb 02 16:26:21 2016 +0100
@@ -298,7 +298,7 @@
 		end
 	end);
 
-	module:add_timer(10, function()
+	module:add_timer(math.random(10, 60), function()
 		local user = next(cleanup);
 		if user then
 			module:log("debug", "Removing old messages for user %q", user);
@@ -308,7 +308,7 @@
 			end
 			cleanup[user] = nil;
 		end
-		return cleanup_interval;
+		return math.random(cleanup_interval, cleanup_interval * 2);
 	end);
 end