]> git.donarmstrong.com Git - infobot.git/commitdiff
- if a forked process "died", forked{}{PID} somehow became $$ - fixed.
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 1 May 2001 12:13:26 +0000 (12:13 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 1 May 2001 12:13:26 +0000 (12:13 +0000)
- chanServCheck now returns bool
- gettimeofday mistakenly used instead of &timeget()
- when nickserv pass accept, call chanserv ops in case nickserv was
  brought back to life.
- fixed up fm ][ code not to use tons of memory - nice rewrite

git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@470 c11ca15a-4712-0410-83d8-924469b57eb5

src/IRC/IrcHelpers.pl
src/IRC/IrcHooks.pl
src/Misc.pl
src/Modules/Freshmeat.pl
src/Shm.pl

index 9e4c1cd37a28def394baa4611401be6c9a3580e9..fc96d2830552281bd702fb6fee1c34f49068e271 100644 (file)
@@ -301,7 +301,7 @@ sub chanServCheck {
 
     if (!defined $chan or $chan =~ /^$/) {
        &WARN("chanServCheck: chan == NULL.");
-       return;
+       return 0;
     }
 
     if ($chan =~ tr/A-Z/a-z/) {
@@ -309,19 +309,20 @@ sub chanServCheck {
     }
 
     if (! &IsChanConf("chanServ_ops") ) {
-       return;
+       return 0;
     }
 
     &DEBUG("chanServCheck($chan) called.");
 
     if ( &IsParam("nickServ_pass") and !$nickserv) {
        &DEBUG("chanServ_ops($chan): nickserv enabled but not alive? (ircCheck)");
-       return;
+       return 0;
     }
-    return if (exists $channels{$chan}{'o'}{$ident});
+    return if (exists $channels{$chan}{'o'}{$ident});
 
     &status("ChanServ ==> Requesting ops for $chan. (chanServCheck)");
     &rawout("PRIVMSG ChanServ :OP $chan $ident");
+    return 1;
 }
 
 1;
index facce2956494632472da5795192316ac62195f14..b1010b9565712a9cf9ea3831ac3c0becec7716dc 100644 (file)
@@ -356,7 +356,7 @@ sub on_endofnames {
 
     # sync time should be done in on_endofwho like in BitchX
     if (exists $cache{jointime}{$chan}) {
-       my $delta_time = sprintf("%.03f", &gettimeofday() - $cache{jointime}{$chan});
+       my $delta_time = sprintf("%.03f", &timeget() - $cache{jointime}{$chan});
        $delta_time    = 0      if ($delta_time < 0);
 
        &status("$b_blue$chan$ob: sync in ${delta_time}s.");
@@ -495,7 +495,7 @@ sub on_join {
        }
 
        ### TODO: move this to &joinchan()?
-       $cache{jointime}{$chan} = &gettimeofday();
+       $cache{jointime}{$chan} = &timeget();
        rawout("WHO $chan");
 
        return;
@@ -684,6 +684,15 @@ sub on_notice {
 
        # password accepted.
        if ($args =~ /^Password a/i) {
+           my $done    = 0;
+
+           foreach ( &ChanConfList("chanServ_ops") ) {
+               next unless &chanServCheck($_);
+               next if ($done);
+               &DEBUG("nickserv activated or restarted; doing chanserv check.");
+               $done++;
+           }
+
            $nickserv++;
        }
     } elsif ($nick =~ /^ChanServ$/i) {         # chanserv.
index ce98779918eb42a8f7046b837bfad065a0812c43..52cbc7bd72aeb1a3e874fbc367103aec71275df5 100644 (file)
@@ -90,7 +90,7 @@ sub timeget {
     if ($no_timehires) {       # fallback.
        return time();
     } else {                   # the real thing.
-       return [gettimeofday()];
+       return gettimeofday();
     }
 }    
 
index 41c013b679d61925354066eb94e2ce16260b80fe..cb6f7fdf262e3c4e4bd45104be91b747f2d3aff2 100644 (file)
@@ -108,13 +108,14 @@ sub randPackage {
 
     if (scalar @fm) {          #1: perfect match of name.
        my $retval;
-       $retval  = "$fm[0] \002(\002$fm[11]\002)\002, ";
-       $retval .= "section $fm[3], ";
-       $retval .= "is $fm[4]. ";
-       $retval .= "Stable: \002$fm[1]\002, ";
-       $retval .= "Development: \002$fm[2]\002. ";
-       $retval .= $fm[5] || $fm[6];             # fallback to 'download'.
-       $retval .= " deb: ".$fm[8] if ($fm[8] ne ""); # 'deb'.
+       $retval  = "$fm[0] \002(\002$fm[5]\002)\002, ";
+#      $retval .= "section $fm[3], ";
+       $retval .= "is $fm[2]. ";
+       $retval .= "Version: \002$fm[1]\002, ";
+#      $retval .= "Development: \002$fm[2]\002. ";
+       $retval .= $fm[4];
+### ???
+#      $retval .= " deb: ".$fm[3] if ($fm[3] ne ""); # 'deb'.
 
        return $retval;
     } else {
@@ -188,11 +189,55 @@ sub downloadIndex {
     @cols      = &::dbGetColInfo("freshmeat");
 
     $locktime  = time();
-    # todo: prevent severe memory usage whilst opening this file!!!
-    $p->parse(*IN, ProtocolEncoding => 'ISO-8859-1');
+
+    # this mess is to not dump IN to memory.
+    $_ = <IN>;
+    $_ = <IN>;
+    $_ = <IN>;
+
+    my $str;
+    while (<IN>) {
+       chop;
+
+       $str .= $_;
+
+       next unless (/<\/project>/);
+
+       # XML::Parser's parse() doesn't like the following.
+       # but parsefile() does... why!
+       for ($str) {
+               s/&reg;/_/g;
+               s/&ocirc;//g;
+               s/&quot;//g;
+               s/&eacute;/e/g;
+               s/&agrave;/a/g;
+               s/&iacute;/i/g;
+               s/&shy;/_/g;    # ???
+               s/&acute;/a/g;
+               s/&raquo;/_/g;  # ???
+               s/&laquo;/_/g;  # ???
+               s/&copy;/[C]/g;
+               s/&deg;/deg/g;
+               s/&AElig;/A/g;
+               s/\cN//g;               # fucking openbsd morons.
+               s/&nbsp;/-/g;
+               s/&ouml;/o/g;
+               s/&para;//g;    # ???
+               s/&atilde;//g;
+               s/\cM/ /g;              # stupid windows morons
+               s/&sup2;/square/g;
+               s/&uuml;/?/g;
+               s/&micro;/u/g;
+               s/&aelig;/a/g;
+               s/&oslash;/o/g;
+               s/&eth;/e/g;
+       }
+
+       $p->parse($str, ProtocolEncoding => 'ISO-8859-1');
+       $str = "";
+    }
     close IN;
 
-    &::DEBUG("FM: data ".scalar(@data) );
     &::dbRaw("UNLOCK", "UNLOCK TABLES");
 
     my $delta_time = &::timedelta($start_time);
@@ -256,11 +301,12 @@ sub freshmeatAnnounce {
     return "Freshmeat update: ".join(" \002::\002 ", @new);
 }
 
+
 sub xml_text {
-    my($expat,$text) = @_;
-    return if ($text =~ /^\s+$/);
+    my ($e,$t) = @_;
+    return if ($t =~ /^\s*$/);
 
-    $string = $text;
+    $string = $t;
 }
 
 sub xml_end {
@@ -268,7 +314,7 @@ sub xml_end {
 
     $pkg{$text} = $string;
 
-    if ($expat->depth == 1) {
+    if ($expat->depth == 0) {
        for (my $j=0; $j<scalar @cols; $j++) {
            $data[$j] = $pkg{ $cols[$j] };
        }
@@ -284,6 +330,9 @@ sub xml_end {
                &::Time2String( time() - $locktime ) );
            $locktime = time();
 
+           # I think the following leaks 120k of memory each time it's
+           # called... the wonders of libmysql-perl leaking!
+
            &::dbRaw("UNLOCK", "UNLOCK TABLES");
            ### another lame hack to "prevent" errors.
            select(undef, undef, undef, 0.2);
index 8d6e5a3882564f546d96305ae0dd80e2bc9827a9..b9756bce3676b6e42d0e778fb9b1dddd73e60491 100644 (file)
@@ -126,9 +126,11 @@ sub addForked {
        my $time        = $forked{$name}{Time};
        my $continue    = 0;
 
-       &DEBUG("PID => $forked{$name}{PID}");
+       $continue++ if ($forked{$name}{PID} == $$);
 
-       if ( -d "/proc/$forked{$name}{PID}") {
+       if ($continue) {
+           &DEBUG("hrm.. fork pid == mypid == $$; how did this happen?");
+       } elsif ( -d "/proc/$forked{$name}{PID}") {
            &status("fork: still running; good. BAIL OUT.");
            return 0;
        } else {