From 07c2345af5dd653ca94894a0ab39222ffc1930a6 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Mon, 6 Dec 2021 17:38:52 +0100 Subject: [PATCH] Fix throttling only cleaning up old entries every 2 minutes. That is, until the first REHASH happened, after that all is good. This was caused by update_throttling_timer_settings() being called before init_throttling(). --- src/api-event.c | 1 + src/hash.c | 8 -------- src/ircd.c | 1 - 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/api-event.c b/src/api-event.c index 9b2b5778e..799edb750 100644 --- a/src/api-event.c +++ b/src/api-event.c @@ -224,4 +224,5 @@ void SetupEvents(void) EventAdd(NULL, "handshake_timeout", handshake_timeout, NULL, 1000, 0); EventAdd(NULL, "tls_check_expiry", tls_check_expiry, NULL, (86400/2)*1000, 0); EventAdd(NULL, "unrealdb_expire_secret_cache", unrealdb_expire_secret_cache, NULL, 61000, 0); + EventAdd(NULL, "throttling_check_expire", throttling_check_expire, NULL, 1000, 0); } diff --git a/src/hash.c b/src/hash.c index deac12437..0901af9c8 100644 --- a/src/hash.c +++ b/src/hash.c @@ -617,14 +617,6 @@ void update_throttling_timer_settings(void) EventMod(EventFind("throttling_check_expire"), &eInfo); } -void init_throttling() -{ - EventAdd(NULL, "throttling_check_expire", throttling_check_expire, NULL, 123456, 0); - /* Note: the every_ms value (123,456) will be adjusted on boot and rehash - * via the update_throttling_timer_settings() function. - */ -} - uint64_t hash_throttling(const char *ip) { return siphash(ip, siphashkey_throttling) % THROTTLING_HASH_TABLE_SIZE; diff --git a/src/ircd.c b/src/ircd.c index 131ce75f7..dbb5554f9 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -1152,7 +1152,6 @@ int InitUnrealIRCd(int argc, char *argv[]) fix_timers(); write_pidfile(); - init_throttling(); loop.booted = 1; #if defined(HAVE_SETPROCTITLE) setproctitle("%s", me.name);