diff options
author | Timo Sirainen <cras@irssi.org> | 2002-03-10 14:31:07 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2002-03-10 14:31:07 +0000 |
commit | 44247af3ffa8356b6422e6f8d24be144807e1bba (patch) | |
tree | 15a2043480d6c1cb568ac6fcfd13239df81af391 /src/irc | |
parent | 8d245f2ddf28378085b19536aacd7f784e3ff8e8 (diff) | |
download | irssi-44247af3ffa8356b6422e6f8d24be144807e1bba.zip |
/KNOCKOUT code was a bit stupid, and the timeout checking wasn't very
/accurate.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2551 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/irc')
-rw-r--r-- | src/irc/core/irc-commands.c | 15 | ||||
-rw-r--r-- | src/irc/core/irc-servers.h | 1 |
2 files changed, 5 insertions, 11 deletions
diff --git a/src/irc/core/irc-commands.c b/src/irc/core/irc-commands.c index 5ecfb482..64b31509 100644 --- a/src/irc/core/irc-commands.c +++ b/src/irc/core/irc-commands.c @@ -52,7 +52,7 @@ typedef struct { IRC_CHANNEL_REC *channel; char *ban; - int timeleft; + time_t unban_time; } KNOCKOUT_REC; static GString *tmpstr; @@ -708,24 +708,19 @@ static void knockout_destroy(IRC_SERVER_REC *server, KNOCKOUT_REC *rec) static void knockout_timeout_server(IRC_SERVER_REC *server) { GSList *tmp, *next; - time_t t; + time_t now; g_return_if_fail(server != NULL); if (!IS_IRC_SERVER(server)) return; - t = server->knockout_lastcheck == 0 ? 0 : - time(NULL)-server->knockout_lastcheck; - server->knockout_lastcheck = time(NULL); - + now = time(NULL); for (tmp = server->knockoutlist; tmp != NULL; tmp = next) { KNOCKOUT_REC *rec = tmp->data; next = tmp->next; - if (rec->timeleft > t) - rec->timeleft -= t; - else { + if (rec->unban_time <= now) { /* timeout, unban. */ ban_remove(rec->channel, rec->ban); knockout_destroy(server, rec); @@ -800,7 +795,7 @@ static void cmd_knockout(const char *data, IRC_SERVER_REC *server, else { /* create knockout record */ rec = g_new(KNOCKOUT_REC, 1); - rec->timeleft = timeleft; + rec->unban_time = time(NULL)+timeleft; rec->channel = channel; rec->ban = banmasks; diff --git a/src/irc/core/irc-servers.h b/src/irc/core/irc-servers.h index 0f4659cd..b0cd84b5 100644 --- a/src/irc/core/irc-servers.h +++ b/src/irc/core/irc-servers.h @@ -87,7 +87,6 @@ struct _IRC_SERVER_REC { /* /knockout ban list */ GSList *knockoutlist; - time_t knockout_lastcheck; GHashTable *splits; /* For keeping track of netsplits */ GSList *split_servers; /* Servers that are currently in split */ |