diff options
author | Jilles Tjoelker <jilles@irssi.org> | 2007-06-06 17:57:28 +0000 |
---|---|---|
committer | jilles <jilles@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2007-06-06 17:57:28 +0000 |
commit | ff63982d4f46d2c671215dcf89cc1b4aa136ac56 (patch) | |
tree | bf1974d5f1ab6bcc44b64eabf4a26f9337723ab2 /src | |
parent | 0bfffb33ce259626d7d1087d2600f7f262bd56d5 (diff) | |
download | irssi-ff63982d4f46d2c671215dcf89cc1b4aa136ac56.zip |
Don't add the same mask to the knockout list multiple times.
This fixes bug #510. Note that #510 only happened if multiple
bans were sent before the MODE came back and multiple unbans
were sent before the MODE came back.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4544 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r-- | src/irc/core/irc-commands.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/irc/core/irc-commands.c b/src/irc/core/irc-commands.c index 6a219433..e829eaa3 100644 --- a/src/irc/core/irc-commands.c +++ b/src/irc/core/irc-commands.c @@ -802,6 +802,7 @@ static void cmd_knockout(const char *data, IRC_SERVER_REC *server, char **nicklist, *spacenicks, *banmasks; void *free_arg; int timeleft; + GSList *ptr; CMD_IRC_SERVER(server); @@ -856,13 +857,20 @@ static void cmd_knockout(const char *data, IRC_SERVER_REC *server, if (*banmasks == '\0') g_free(banmasks); else { - /* create knockout record */ - rec = g_new(KNOCKOUT_REC, 1); + /* check if we already have this knockout */ + for (ptr = server->knockoutlist; ptr != NULL; ptr = ptr->next) { + rec = ptr->data; + if (channel == rec->channel && + !strcmp(rec->ban, banmasks)) + break; + } + if (ptr == NULL) { + rec = g_new(KNOCKOUT_REC, 1); + rec->channel = channel; + rec->ban = banmasks; + server->knockoutlist = g_slist_append(server->knockoutlist, rec); + } rec->unban_time = time(NULL)+timeleft/1000; - rec->channel = channel; - rec->ban = banmasks; - - server->knockoutlist = g_slist_append(server->knockoutlist, rec); } cmd_params_free(free_arg); |