changeset 1854:450ada5bb1b5

mod_limit_auth: Get rid of old inactive throttle objects
author Kim Alvefur <zash@zash.se>
date Mon, 14 Sep 2015 13:03:02 +0200
parents c25a0ac8b511
children 7eef1a3a2a17
files mod_limit_auth/mod_limit_auth.lua
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_limit_auth/mod_limit_auth.lua	Mon Sep 14 12:59:48 2015 +0200
+++ b/mod_limit_auth/mod_limit_auth.lua	Mon Sep 14 13:03:02 2015 +0200
@@ -46,4 +46,12 @@
 	get_throttle(event.session.ip):poll(1);
 end);
 
--- TODO remove old throttles after some time
+module:add_timer(14400, function (now)
+	local old = now - 86400;
+	for ip, throttle in pairs(throttles) do
+		if throttle.t < old then
+			throttles[ip] = nil;
+		end
+	end
+end);
+