[LON-CAPA-cvs] cvs: loncom / lond

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 17 Feb 2004 21:02:37 -0000


albertel		Tue Feb 17 16:02:37 2004 EDT

  Modified files:              
    /loncom	lond 
  Log:
  - throw away lines starting with #
  - REAPER double checks the children hash for noexistant children
  - removed nolonger useful children counter
  
  
Index: loncom/lond
diff -u loncom/lond:1.175 loncom/lond:1.176
--- loncom/lond:1.175	Tue Feb 17 15:07:25 2004
+++ loncom/lond	Tue Feb 17 16:02:37 2004
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.175 2004/02/17 20:07:25 albertel Exp $
+# $Id: lond,v 1.176 2004/02/17 21:02:37 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -53,7 +53,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.175 $'; #' stupid emacs
+my $VERSION='$Revision: 1.176 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid;
 my $currentdomainid;
@@ -812,7 +812,6 @@
 # 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;
@@ -822,12 +821,18 @@
 	$pid = waitpid(-1,&WNOHANG());
 	if (defined($children{$pid})) {
 	    &logthis("Child $pid died");
-	    $children --;
-	    delete $children{$pid};
+	    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");
 }
 
@@ -882,12 +887,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);
 }
@@ -1259,7 +1266,6 @@
         sigprocmask(SIG_UNBLOCK, $sigset)
             or die "Can't unblock SIGINT for fork: $!\n";
         $children{$pid} = $clientip;
-        $children++;
         &status('Started child '.$pid);
         return;
     } else {