mirror of
https://github.com/irssi/irssi.git
synced 2025-01-03 14:56:47 -05:00
/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
This commit is contained in:
parent
8d245f2ddf
commit
44247af3ff
@ -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;
|
||||
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user