]> git.donarmstrong.com Git - infobot.git/blobdiff - src/IRC/Schedulers.pl
standard TODO: and FIXME:
[infobot.git] / src / IRC / Schedulers.pl
index 5ef67f8be602f620e49849aed8ffcdd4cbbd9aab..00dabb3889e400442e2ffd4d74e701cf9ea7d199 100644 (file)
@@ -77,10 +77,10 @@ sub setupSchedulers {
     &kernelLoop(2);
     &wingateWriteFile(2);
     &factoidCheck(2);  # takes a couple of seconds on a 486. defer it
-# todo: convert to new format... or nuke altogether.
+# TODO: convert to new format... or nuke altogether.
     &newsFlush(1);
 
-    # todo: squeeze this into a one-liner.
+    # TODO: squeeze this into a one-liner.
 #    my $count = map { exists $sched{$_}{TIME} } keys %sched;
     my $count  = 0;
     foreach (keys %sched) {
@@ -327,7 +327,7 @@ sub newsFlush {
 
            next unless (time() > $t);
 
-           # todo: show how old it was.
+           # TODO: show how old it was.
            delete $::news{$chan}{$item};
            &status("NEWS: (newsflush) deleted '$item'");
            $delete++;
@@ -338,7 +338,7 @@ sub newsFlush {
        $none{$chan} = 1 if ($total == $i);
     }
 
-    # todo: flush users aswell.
+    # TODO: flush users aswell.
     my $duser  = 0;
     foreach $chan (keys %::newsuser) {
        next if (exists $none{$chan});
@@ -399,7 +399,7 @@ sub chanlimitCheck {
        }
 
        if (defined $limit and scalar keys %{ $channels{$chan}{''} } > $limit) {
-           &FIXME("LIMIT: set too low!!! FIXME");
+           &FIXME("LIMIT: set too low!!!");
            ### run NAMES again and flush it.
        }
 
@@ -417,7 +417,7 @@ sub chanlimitCheck {
        delete $cache{warn}{chanlimit}{$chan};
 
        if (!defined $limit) {
-           &status("chanlimit: setting for first time or from netsplit, for $chan");
+           &status("chanlimit: $chan: setting for first time or from netsplit.");
        }
 
        if (exists $cache{chanlimitChange}{$chan}) {
@@ -678,15 +678,15 @@ sub ircCheck {
     my $iconf  = scalar( @x );
     my $inow   = scalar( keys %channels );
     if ($iconf > 2 and $inow * 2 <= $iconf) {
-       &FIXME("ircCheck: current channels * 2 <= config channels. FIXME.");
-       &FIXME("ircCheck: iconf = $iconf");
-       &FIXME("ircCheck: inow  = $inow");
+       &FIXME("ircCheck: current channels ($inow) * 2 <= config channels ($iconf).");
 #      @joinchan       = @x;
        &joinNextChan();
     }
 
-    if (!$conn->connected or time() - $msgtime > 3600) {
-       # todo: shouldn't we use cache{connect} somewhere?
+    # TODO: fix on_disconnect()
+
+    if (time() - $msgtime > 3600) {
+       # TODO: shouldn't we use cache{connect} somewhere?
        if (exists $cache{connect}) {
            &WARN("ircCheck: no msg for 3600 and disco'd! reconnecting!");
            $msgtime = time();  # just in case.
@@ -761,13 +761,18 @@ sub miscCheck {
        my ($shmid, $size) = ($2,$5);
        next unless ($shmid != $shm and $size == 2000);
        my $z   = &shmRead($shmid);
-       if ($z =~ /^(\d+): /) {
-           my $time    = $1;
+       if ($z =~ /^(\S+):(\d+):(\d+): /) {
+           my $n       = $1;
+           my $pid     = $2;
+           my $time    = $3;
            next if (time() - $time < 60*60);
-
+           # FIXME remove not-pid shm if parent process dead
+           next if ($pid == $bot_pid);
+           # don't touch other bots, if they're running.
+           next unless ($param{ircNick} =~ /^\Q$n\E$/);
        } else {
-#          &DEBUG("shm: $shmid is not ours or old blootbot => ($z)");
-#          next;
+           &DEBUG("shm: $shmid is not ours or old blootbot => ($z)");
+           next;
        }
 
        &status("SHM: nuking shmid $shmid");
@@ -807,7 +812,7 @@ sub miscCheck2 {
     closedir DEBIAN;
 
     # compress logs that should have been compressed.
-    # todo: use strftime?
+    # TODO: use strftime?
     my ($day,$month,$year) = (gmtime(time()))[3,4,5];
     my $date = sprintf("%04d%02d%02d",$year+1900,$month+1,$day);
 
@@ -958,7 +963,7 @@ sub wingateCheck {
     undef @wingateNow;
 }
 
-### TODO.
+### TODO: ??
 sub wingateWriteFile {
     if (@_) {
        &ScheduleThis(60, "wingateWriteFile");
@@ -1007,7 +1012,7 @@ sub factoidCheck {
     my $time   = time();
 
     foreach (@list) {
-       my $age = &getFactInfo($_, "modified_time");    
+       my $age = &getFactInfo($_, "modified_time");
 
        if (!defined $age or $age !~ /^\d+$/) {
            if (scalar @list > 50) {