forked from PsychoticNinja/irssi
Check for stale flood entries when lines come in, avoiding a 0.5 second timeout.
The timeout is now every 5 seconds and serves to remove entries that do not send messages anymore. git-svn-id: file:///var/www/svn.irssi.org/SVN/irssi/trunk@5024 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
c57f58dea5
commit
2dd265ef39
@ -186,7 +186,8 @@ static void flood_newmsg(IRC_SERVER_REC *server, int level, const char *nick,
|
||||
MODULE_SERVER_REC *mserver;
|
||||
FLOOD_REC *flood;
|
||||
FLOOD_ITEM_REC *rec;
|
||||
time_t *ttime;
|
||||
time_t now, *ttime;
|
||||
GSList *times, *tnext;
|
||||
|
||||
g_return_if_fail(server != NULL);
|
||||
g_return_if_fail(nick != NULL);
|
||||
@ -196,8 +197,19 @@ static void flood_newmsg(IRC_SERVER_REC *server, int level, const char *nick,
|
||||
|
||||
rec = flood == NULL ? NULL : flood_find(flood, level, target);
|
||||
if (rec != NULL) {
|
||||
now = time(NULL);
|
||||
for (times = rec->msgtimes; times != NULL; times = tnext) {
|
||||
time_t *data = times->data;
|
||||
tnext = times->next;
|
||||
|
||||
if (now - *data >= flood_timecheck) {
|
||||
rec->msgtimes = g_slist_remove(rec->msgtimes, data);
|
||||
g_free(data);
|
||||
} else
|
||||
break;
|
||||
}
|
||||
ttime = g_new(time_t, 1);
|
||||
*ttime = time(NULL);
|
||||
*ttime = now;
|
||||
rec->msgtimes = g_slist_append(rec->msgtimes, ttime);
|
||||
if (g_slist_length(rec->msgtimes) > flood_max_msgs) {
|
||||
/* flooding! */
|
||||
@ -287,7 +299,7 @@ static void read_settings(void)
|
||||
|
||||
if (flood_timecheck > 0 && flood_max_msgs > 0) {
|
||||
if (flood_tag == -1) {
|
||||
flood_tag = g_timeout_add(500, (GSourceFunc) flood_timeout, NULL);
|
||||
flood_tag = g_timeout_add(5000, (GSourceFunc) flood_timeout, NULL);
|
||||
|
||||
signal_add("event privmsg", (SIGNAL_FUNC) flood_privmsg);
|
||||
signal_add("event notice", (SIGNAL_FUNC) flood_notice);
|
||||
|
Loading…
x
Reference in New Issue
Block a user