&leakCheck(2); # mandatory
&ignoreCheck(1); # mandatory
&seenFlushOld(2);
-# &ircCheck(2); # mandatory
&ircCheck(1); # mandatory
&miscCheck(1); # mandatory
&miscCheck2(2); # mandatory
&freshmeatLoop(2);
&kernelLoop(2);
&wingateWriteFile(2);
- &factoidCheck(1);
+ &factoidCheck(2); # takes a couple of seconds on a 486. defer it
&newsFlush(1);
# my $count = map { exists $sched{$_}{TIME} } keys %sched;
}
### check if all the logs exceed size.
- my $logdir = "$bot_base_dir/log/";
- if (opendir(LOGS, $logdir)) {
+ if (opendir(LOGS, $bot_log_dir)) {
my $tsize = 0;
my (%age, %size);
while (defined($_ = readdir LOGS)) {
- my $logfile = "$logdir/$_";
+ my $logfile = "$bot_log_dir/$_";
next unless ( -f $logfile);
my $size = -s $logfile;
### TODO: add how many b,kb,mb removed?
&status("LOG: removed $delete logs.") if ($delete);
} else {
- &WARN("could not open dir $logdir");
+ &WARN("could not open dir $bot_log_dir");
}
}
}
$cache{'netsplitCache'}++;
- &DEBUG("running netsplitCheck... $cache{netsplitCache}");
+# &DEBUG("running netsplitCheck... $cache{netsplitCache}");
if (!scalar %netsplit and scalar %netsplitservers) {
&DEBUG("nsC: !hash netsplit but hash netsplitservers <- removing!");
if ($delete) {
my $j = scalar(keys %netsplit);
- &DEBUG("nsC: removed from netsplit list: (before: $count; after: $j)");
+ &status("nsC: removed from netsplit list: (before: $count; after: $j)");
}
if (!scalar %netsplit and scalar %netsplitservers) {
$count += scalar(keys %{ $flood{$blah1}{$blah2} });
}
}
- &DEBUG("leak: hash flood has $count total keys.",2);
+ &VERB("leak: hash flood has $count total keys.",2);
# floodjoin.
$count = 0;
$count += scalar(keys %{ $floodjoin{$blah1}{$blah2} });
}
}
- &DEBUG("leak: hash floodjoin has $count total keys.",2);
+ &VERB("leak: hash floodjoin has $count total keys.",2);
# floodwarn.
$count = scalar(keys %floodwarn);
- &DEBUG("leak: hash floodwarn has $count total keys.",2);
+ &VERB("leak: hash floodwarn has $count total keys.",2);
my $chan;
foreach $chan (grep /[A-Z]/, keys %channels) {
# chanstats
$count = scalar(keys %chanstats);
- &DEBUG("leak: hash chanstats has $count total keys.",2);
+ &VERB("leak: hash chanstats has $count total keys.",2);
# nuh.
my $delete = 0;
$count++;
}
}
+
+ $cache{ignoreCheckTime} = time();
+
&VERB("ignore: $count items deleted.",2);
}
return if ($_[0] eq "2"); # defer.
}
+ $cache{statusSafe} = 1;
+
my @x = &getJoinChans();
my $iconf = scalar( @x );
my $inow = scalar( keys %channels );
if ($iconf > 2 and $inow * 2 <= $iconf) {
&FIXME("ircCheck: current channels * 2 <= config channels. FIXME.");
- @joinchan = @x;
+ &FIXME("ircCheck: iconf = $iconf");
+ &FIXME("ircCheck: inow = $inow");
+# @joinchan = @x;
&joinNextChan();
}
if (grep /^\s*$/, keys %channels) {
&WARN("ircCheck: we have a NULL chan in hash channels? removing!");
- if (exists $channels{''}) {
- &DEBUG("ircCheck: ok it existed!");
- } else {
- &DEBUG("ircCheck: this hsould never happen!");
+ if (!exists $channels{''}) {
+ &DEBUG("ircCheck: this should never happen!");
}
delete $channels{''};
}
+ $cache{statusSafe} = 0;
+
### USER FILE.
if ($utime_userfile > $wtime_userfile and time() - $wtime_userfile > 3600) {
&writeUserFile();
sub miscCheck {
if (@_) {
- &ScheduleThis(240, "miscCheck");
+ &ScheduleThis(120, "miscCheck");
return if ($_[0] eq "2"); # defer.
}
}
# debian check.
- opendir(DEBIAN, "$bot_base_dir/debian");
+ opendir(DEBIAN, "$bot_state_dir/debian");
foreach ( grep /gz$/, readdir(DEBIAN) ) {
- my $exit = CORE::system("gzip -t $bot_base_dir/debian/$_");
+ my $exit = CORE::system("gzip -t $bot_state_dir/debian/$_");
next unless ($exit);
&status("debian: unlinking file => $_");
- unlink "$bot_base_dir/debian/$_";
+ unlink "$bot_state_dir/debian/$_";
}
closedir DEBIAN;
closedir DIR;
}
-sub shmFlush {
- return if ($$ != $::bot_pid); # fork protection.
-
- if (@_) {
- &ScheduleThis(5, "shmFlush");
- return if ($_[0] eq "2");
- }
-
- my $time;
- my $shmmsg = &shmRead($shm);
- $shmmsg =~ s/\0//g; # remove padded \0's.
- if ($shmmsg =~ s/^(\d+): //) {
- $time = $1;
- }
-
- foreach (split '\|\|', $shmmsg) {
- next if (/^$/);
- &VERB("shm: Processing '$_'.",2);
-
- if (/^DCC SEND (\S+) (\S+)$/) {
- my ($nick,$file) = ($1,$2);
- if (exists $dcc{'SEND'}{$who}) {
- &msg($nick, "DCC already active.");
- } else {
- &DEBUG("shm: dcc sending $2 to $1.");
- $conn->new_send($1,$2);
- $dcc{'SEND'}{$who} = time();
- }
- } elsif (/^SET FORKPID (\S+) (\S+)/) {
- $forked{$1}{PID} = $2;
- } elsif (/^DELETE FORK (\S+)$/) {
- delete $forked{$1};
- } elsif (/^EVAL (.*)$/) {
- &DEBUG("evaling '$1'.");
- eval $1;
- } else {
- &DEBUG("shm: unknown msg. ($_)");
- }
- }
-
- &shmWrite($shm,"") if ($shmmsg ne "");
-}
-
### this is semi-scheduled
sub getNickInUse {
if ($ident eq $param{'ircNick'}) {
&DEBUG("end of sList.");
}
-sub getChanConfDefault {
- my($what, $default, $chan) = @_;
-
- if (exists $param{$what}) {
- if (!exists $cache{config}{$what}) {
- &status("conf: backward-compat: found param{$what} ($param{$what}) instead.");
- $cache{config}{$what} = 1;
- }
-
- return $param{$what};
- }
-
- my $val = &getChanConf($what, $chan);
- if (defined $val) {
- return $val;
- }
-
- $param{$what} = $default;
- &status("conf: auto-setting param{$what} = $default");
- $cache{config}{$what} = 1;
-
- return $default;
-}
-
sub mkBackup {
my($file, $time) = @_;
my $backup = 0;