Diff for /loncom/lond between versions 1.62 and 1.65

version 1.62, 2001/12/22 21:46:02 version 1.65, 2002/02/05 17:17:49
Line 46 Line 46
 # 11/26,11/27 Gerd Kortemeyer  # 11/26,11/27 Gerd Kortemeyer
 # 12/20 Scott Harrison  # 12/20 Scott Harrison
 # 12/22 Gerd Kortemeyer  # 12/22 Gerd Kortemeyer
 #  # YEAR=2002
   # 01/20/02,02/05 Gerd Kortemeyer
 ###  ###
   
 # based on "Perl Cookbook" ISBN 1-56592-243-3  # based on "Perl Cookbook" ISBN 1-56592-243-3
Line 84  sub catchexception { Line 85  sub catchexception {
     die($error);      die($error);
 }  }
   
   sub timeout {
       &logthis("<font color=ref>CRITICAL: TIME OUT ".$$."</font>");
       &catchexception('Timeout');
   }
 # -------------------------------- Set signal handlers to record abnormal exits  # -------------------------------- Set signal handlers to record abnormal exits
   
 $SIG{'QUIT'}=\&catchexception;  $SIG{'QUIT'}=\&catchexception;
Line 187  sub checkchildren { Line 192  sub checkchildren {
     &initnewstatus();      &initnewstatus();
     &logstatus();      &logstatus();
     &logthis('Going to check on the children');      &logthis('Going to check on the children');
       $docdir=$perlvar{'lonDocRoot'};
     foreach (sort keys %children) {      foreach (sort keys %children) {
  sleep 1;   sleep 1;
         unless (kill 'USR1' => $_) {          unless (kill 'USR1' => $_) {
Line 194  sub checkchildren { Line 200  sub checkchildren {
             &logstatus($$.' is dead');              &logstatus($$.' is dead');
         }           } 
     }      }
       sleep 5;
       foreach (sort keys %children) {
           unless (-e "$docdir/lon-status/londchld/$_.txt") {
       &logthis('Child '.$_.' did not respond');
               kill 9 => $_;
           }
       }
 }  }
   
 # --------------------------------------------------------------------- Logging  # --------------------------------------------------------------------- Logging
Line 212  sub logthis { Line 225  sub logthis {
   
 sub logstatus {  sub logstatus {
     my $docdir=$perlvar{'lonDocRoot'};      my $docdir=$perlvar{'lonDocRoot'};
       {
     my $fh=IO::File->new(">>$docdir/lon-status/londstatus.txt");      my $fh=IO::File->new(">>$docdir/lon-status/londstatus.txt");
     print $fh $$."\t".$status."\t".$lastlog."\n";      print $fh $$."\t".$status."\t".$lastlog."\n";
       $fh->close();
       }
       {
    my $fh=IO::File->new(">$docdir/lon-status/londchld/$$.txt");
           print $fh $status."\n".$lastlog."\n".time;
           $fh->close();
       }
 }  }
   
 sub initnewstatus {  sub initnewstatus {
Line 222  sub initnewstatus { Line 243  sub initnewstatus {
     my $now=time;      my $now=time;
     my $local=localtime($now);      my $local=localtime($now);
     print $fh "LOND status $local - parent $$\n\n";      print $fh "LOND status $local - parent $$\n\n";
       opendir(DIR,"$docdir/lon-status/londchld");
       while ($filename=readdir(DIR)) {
           unlink("$docdir/lon-status/londchld/$filename");
       }
       closedir(DIR);
 }  }
   
 # -------------------------------------------------------------- Status setting  # -------------------------------------------------------------- Status setting
Line 431  sub make_new_child { Line 457  sub make_new_child {
         # Child can *not* return from this subroutine.          # Child can *not* return from this subroutine.
         $SIG{INT} = 'DEFAULT';      # make SIGINT kill us as it did before          $SIG{INT} = 'DEFAULT';      # make SIGINT kill us as it did before
         $SIG{USR1}= \&logstatus;          $SIG{USR1}= \&logstatus;
           $SIG{ALRM}= \&timeout;
         $lastlog='Forked ';          $lastlog='Forked ';
         $status='Forked';          $status='Forked';
   
Line 499  sub make_new_child { Line 526  sub make_new_child {
                 chomp($userinput);                  chomp($userinput);
                 &status('Processing '.$hostid{$clientip}.': '.$userinput);                  &status('Processing '.$hostid{$clientip}.': '.$userinput);
                 my $wasenc=0;                  my $wasenc=0;
                   alarm(120);
 # ------------------------------------------------------------ See if encrypted  # ------------------------------------------------------------ See if encrypted
  if ($userinput =~ /^enc/) {   if ($userinput =~ /^enc/) {
   if ($cipher) {    if ($cipher) {
Line 677  sub make_new_child { Line 705  sub make_new_child {
                                $fpnow.='/'.$fpparts[$i];                                  $fpnow.='/'.$fpparts[$i]; 
                                unless (-e $fpnow) {                                 unless (-e $fpnow) {
    unless (mkdir($fpnow,0777)) {     unless (mkdir($fpnow,0777)) {
                                       $fperror="error:$!\n";                                        $fperror="error:$!";
                                    }                                     }
                                }                                 }
                            }                             }
Line 1335  sub make_new_child { Line 1363  sub make_new_child {
                        print $client "unknown_cmd\n";                         print $client "unknown_cmd\n";
                    }                     }
 # -------------------------------------------------------------------- complete  # -------------------------------------------------------------------- complete
      alarm(0);
                    &status('Listening to '.$hostid{$clientip});                     &status('Listening to '.$hostid{$clientip});
        }         }
 # --------------------------------------------- client unknown or fishy, refuse  # --------------------------------------------- client unknown or fishy, refuse

Removed from v.1.62  
changed lines
  Added in v.1.65


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>