[LON-CAPA-cvs] cvs: loncom(version_1_1_X) / lond

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 08 Mar 2004 20:13:07 -0000


albertel		Mon Mar  8 15:13:07 2004 EDT

  Modified files:              (Branch: version_1_1_X)
    /loncom	lond 
  Log:
  - backport 1.175 and 1.176
  
  
Index: loncom/lond
diff -u loncom/lond:1.165.2.2 loncom/lond:1.165.2.3
--- loncom/lond:1.165.2.2	Thu Jan 15 13:56:11 2004
+++ loncom/lond	Mon Mar  8 15:13:07 2004
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.165.2.2 2004/01/15 18:56:11 albertel Exp $
+# $Id: lond,v 1.165.2.3 2004/03/08 20:13:07 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -52,7 +52,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.165.2.2 $'; #' stupid emacs
+my $VERSION='$Revision: 1.165.2.3 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid;
 my $currentdomainid;
@@ -577,18 +577,26 @@
 # global variables
 
 my %children               = ();       # keys are current child process IDs
-my $children               = 0;        # current number of children
 
 sub REAPER {                        # takes care of dead children
     $SIG{CHLD} = \&REAPER;
     &status("Handling child death");
-    my $pid = wait;
-    if (defined($children{$pid})) {
-	&logthis("Child $pid died");
-	$children --;
-	delete $children{$pid};
-    } else {
-	&logthis("Unknown Child $pid died");
+    my $pid;
+    do {
+	$pid = waitpid(-1,&WNOHANG());
+	if (defined($children{$pid})) {
+	    &logthis("Child $pid died");
+	    delete($children{$pid});
+	} else {
+	    &logthis("Unknown Child $pid died");
+	}
+    } while ( $pid > 0 );
+    foreach my $child (keys(%children)) {
+	$pid = waitpid($child,&WNOHANG());
+	if ($pid > 0) {
+	    &logthis("Child $child - $pid looks like we missed it's death");
+	    delete($children{$pid});
+	}
     }
     &status("Finished Handling child death");
 }
@@ -644,12 +652,14 @@
     open (CONFIG,"$perlvar{'lonTabDir'}/hosts.tab") || die "Can't read host file";
     
     while (my $configline=<CONFIG>) {
-	my ($id,$domain,$role,$name,$ip)=split(/:/,$configline);
-	chomp($ip); $ip=~s/\D+$//;
-	$hostid{$ip}=$id;
-	$hostdom{$id}=$domain;
-	$hostip{$id}=$ip;
-	if ($id eq $perlvar{'lonHostID'}) { $thisserver=$name; }
+	if (!($configline =~ /^\s*\#/)) {
+	    my ($id,$domain,$role,$name,$ip)=split(/:/,$configline);
+	    chomp($ip); $ip=~s/\D+$//;
+	    $hostid{$ip}=$id;
+	    $hostdom{$id}=$domain;
+	    $hostip{$id}=$ip;
+	    if ($id eq $perlvar{'lonHostID'}) { $thisserver=$name; }
+	}
     }
     close(CONFIG);
 }
@@ -785,7 +795,7 @@
     my $docdir=$perlvar{'lonDocRoot'};
     {
     my $fh=IO::File->new(">>$docdir/lon-status/londstatus.txt");
-    print $fh $$."\t".$currenthostid."\t".$status."\t".$lastlog."\n";
+    print $fh $$."\t".$clientname."\t".$currenthostid."\t".$status."\t".$lastlog."\n";
     $fh->close();
     }
     &status("Finished londstatus.txt");
@@ -1021,7 +1031,6 @@
         sigprocmask(SIG_UNBLOCK, $sigset)
             or die "Can't unblock SIGINT for fork: $!\n";
         $children{$pid} = $clientip;
-        $children++;
         &status('Started child '.$pid);
         return;
     } else {