diff --git a/Changes b/Changes index 932d23c74..cea4f1703 100644 --- a/Changes +++ b/Changes @@ -1742,3 +1742,6 @@ minutes if the clock was set backwards, until the time is OK again (catches up with the original time). This fixes #0003230 reported by Stealth, and #0002521 reported by durrie. +- Throttling time is now more accurate, especially with larger time values + such as 3 connections per 60 seconds. Previously that could result in 3 per + 90 seconds due to timer inaccuracy, now max 65 seconds (max 5s inaccuracy). diff --git a/src/hash.c b/src/hash.c index 6dc1bd53a..84c89169e 100644 --- a/src/hash.c +++ b/src/hash.c @@ -781,9 +781,17 @@ struct MODVAR ThrottlingBucket *ThrottlingHash[THROTTLING_HASH_SIZE+1]; void init_throttling_hash() { +long v; bzero(ThrottlingHash, sizeof(ThrottlingHash)); - EventAddEx(NULL, "bucketcleaning", (THROTTLING_PERIOD ? THROTTLING_PERIOD : 120)/2, 0, - e_clean_out_throttling_buckets, NULL); + if (!THROTTLING_PERIOD) + v = 120; + else + { + v = THROTTLING_PERIOD/2; + if (v > 5) + v = 5; /* accuracy, please */ + } + EventAddEx(NULL, "bucketcleaning", v, 0, e_clean_out_throttling_buckets, NULL); } int hash_throttling(struct IN_ADDR *in) diff --git a/src/s_conf.c b/src/s_conf.c index ec0dd741d..a4e832e7e 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -2339,8 +2339,17 @@ int config_run() #ifdef THROTTLING { EventInfo eInfo; + long v; eInfo.flags = EMOD_EVERY; - eInfo.every = THROTTLING_PERIOD ? THROTTLING_PERIOD/2 : 86400; + if (!THROTTLING_PERIOD) + v = 120; + else + { + v = THROTTLING_PERIOD/2; + if (v > 5) + v = 5; /* accuracy, please */ + } + eInfo.every = v; EventMod(EventFind("bucketcleaning"), &eInfo); } #endif