mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-06 22:03:12 +02:00
Fix warning about EventAdd with 2msec value.
Reported by ivanp in https://bugs.unrealircd.org/view.php?id=5540 This cleans things up a bit as well (remove duplicate code).
This commit is contained in:
+2
-1
@@ -93,7 +93,7 @@ extern MODVAR ConfigItem_offchans *conf_offchans;
|
||||
extern void completed_connection(int, int, void *);
|
||||
extern void clear_unknown();
|
||||
extern EVENT(e_unload_module_delayed);
|
||||
extern EVENT(e_clean_out_throttling_buckets);
|
||||
extern EVENT(throttling_check_expire);
|
||||
|
||||
extern void module_loadall(void);
|
||||
extern long set_usermode(char *umode);
|
||||
@@ -964,3 +964,4 @@ extern char *unreal_add_quotes(char *str);
|
||||
extern int unreal_add_quotes_r(char *i, char *o, size_t len);
|
||||
extern void user_account_login(MessageTag *recv_mtags, Client *client);
|
||||
extern void link_generator(void);
|
||||
extern void update_throttling_timer_settings(void);
|
||||
|
||||
+1
-19
@@ -2730,25 +2730,7 @@ int config_run()
|
||||
free_iConf(&iConf);
|
||||
memcpy(&iConf, &tempiConf, sizeof(iConf));
|
||||
memset(&tempiConf, 0, sizeof(tempiConf));
|
||||
|
||||
{
|
||||
EventInfo eInfo;
|
||||
long v;
|
||||
eInfo.flags = EMOD_EVERY;
|
||||
if (!THROTTLING_PERIOD)
|
||||
v = 120000;
|
||||
else
|
||||
{
|
||||
v = THROTTLING_PERIOD/2;
|
||||
if (v > 5)
|
||||
v = 5000; /* accuracy, please */
|
||||
if (v < 1)
|
||||
v = 1000; /* duh */
|
||||
}
|
||||
eInfo.every_msec = v;
|
||||
EventMod(EventFind("bucketcleaning"), &eInfo);
|
||||
}
|
||||
|
||||
update_throttling_timer_settings();
|
||||
|
||||
/* initialize conf_files with defaults if the block isn't set: */
|
||||
if(!conf_files)
|
||||
|
||||
+20
-7
@@ -886,22 +886,35 @@ int hash_del_watch_list(Client *client)
|
||||
|
||||
struct MODVAR ThrottlingBucket *ThrottlingHash[THROTTLING_HASH_TABLE_SIZE];
|
||||
|
||||
void init_throttling()
|
||||
void update_throttling_timer_settings(void)
|
||||
{
|
||||
long v;
|
||||
EventInfo eInfo;
|
||||
|
||||
if (!THROTTLING_PERIOD)
|
||||
{
|
||||
v = 120;
|
||||
v = 120*1000;
|
||||
} else
|
||||
{
|
||||
v = THROTTLING_PERIOD/2;
|
||||
if (v > 5)
|
||||
v = (THROTTLING_PERIOD*1000)/2;
|
||||
if (v > 5000)
|
||||
v = 5000; /* run at least every 5s */
|
||||
if (v < 1)
|
||||
if (v < 1000)
|
||||
v = 1000; /* run at max once every 1s */
|
||||
}
|
||||
EventAdd(NULL, "bucketcleaning", e_clean_out_throttling_buckets, NULL, v, 0);
|
||||
|
||||
memset(&eInfo, 0, sizeof(eInfo));
|
||||
eInfo.flags = EMOD_EVERY;
|
||||
eInfo.every_msec = v;
|
||||
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(char *ip)
|
||||
@@ -924,7 +937,7 @@ struct ThrottlingBucket *find_throttling_bucket(Client *client)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EVENT(e_clean_out_throttling_buckets)
|
||||
EVENT(throttling_check_expire)
|
||||
{
|
||||
struct ThrottlingBucket *n, *n_next;
|
||||
int i;
|
||||
|
||||
Reference in New Issue
Block a user