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

foxr lon-capa-cvs@mail.lon-capa.org
Wed, 22 Sep 2004 11:11:54 -0000


foxr		Wed Sep 22 07:11:54 2004 EDT

  Modified files:              
    /loncom	loncnew 
  Log:
  Add toplevel flow control for switching loncnew to monitoring the 
  lonnet socket and forking off kids that then die when their connection
  count gets trimmed back to 0.  All this is conditionalized on the
  DieWhenIdle variable which MUST NOT BE SET NONZERO as the support is
  incomplete.  The variable is there so that I can commit my changes
  and continue to test but not affect the current working loncnew
  SO KEEP YOUR HANDS OFF IT:
  
  Oh, and by the way, did I mention that you should not modify the
  DieWhenIdle variable?
  
  
  
Index: loncom/loncnew
diff -u loncom/loncnew:1.59 loncom/loncnew:1.60
--- loncom/loncnew:1.59	Wed Sep 22 06:46:06 2004
+++ loncom/loncnew	Wed Sep 22 07:11:54 2004
@@ -2,7 +2,7 @@
 # The LearningOnline Network with CAPA
 # lonc maintains the connections to remote computers
 #
-# $Id: loncnew,v 1.59 2004/09/22 10:46:06 foxr Exp $
+# $Id: loncnew,v 1.60 2004/09/22 11:11:54 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -106,6 +106,9 @@
 my $KeyMode         = "";       # e.g. ssl, local, insecure from last connect.
 my $LondConnecting  = 0;       # True when a connection is being built.
 
+
+# DO NOT SET THE NEXT VARIABLE TO NON ZERO!!!!!!!!!!!!!!!
+
 my $DieWhenIdle     = 0;	# When true children die when trimmed -> 0.
 
 #
@@ -1689,13 +1692,21 @@
 
 LondConnection::ReadConfig;               # Read standard config files.
 my $HostIterator = LondConnection::GetHostIterator;
-while (! $HostIterator->end()) {
 
-    my $hostentryref = $HostIterator->get();
-    CreateChild($hostentryref->[0]);
-    $HostHash{$hostentryref->[0]} = $hostentryref->[4];
-    $HostIterator->next();
+if ($DieWhenIdle) {
+    print "Die when idle socket monitoring is not yet implemented\n";
+    exit(-1);
+} else {
+    
+    while (! $HostIterator->end()) {
+	
+	my $hostentryref = $HostIterator->get();
+	CreateChild($hostentryref->[0]);
+	$HostHash{$hostentryref->[0]} = $hostentryref->[4];
+	$HostIterator->next();
+    }
 }
+
 $RemoteHost = "Parent Server";
 
 # Maintain the population:
@@ -1706,27 +1717,32 @@
 #   Set up parent signals:
 #
 
-$SIG{INT}  = \&Terminate;
-$SIG{TERM} = \&Terminate; 
-$SIG{HUP}  = \&Restart;
-$SIG{USR1} = \&CheckKids; 
-$SIG{USR2} = \&UpdateKids;	# LonManage update request.
-
-while(1) {
-    my $deadchild = wait();
-    if(exists $ChildHash{$deadchild}) {	# need to restart.
-	my $deadhost = $ChildHash{$deadchild};
-	delete($HostToPid{$deadhost});
-	delete($ChildHash{$deadchild});
-	Log("WARNING","Lost child pid= ".$deadchild.
-	      "Connected to host ".$deadhost);
-	Log("INFO", "Restarting child procesing ".$deadhost);
-	CreateChild($deadhost);
+if ($DieWhenIdle) {
+    print "Die when idle main processing not yet implemented";
+    exit (-1);
+} else {
+    
+    $SIG{INT}  = \&Terminate;
+    $SIG{TERM} = \&Terminate; 
+    $SIG{HUP}  = \&Restart;
+    $SIG{USR1} = \&CheckKids; 
+    $SIG{USR2} = \&UpdateKids;	# LonManage update request.
+    
+    while(1) {
+	my $deadchild = wait();
+	if(exists $ChildHash{$deadchild}) {	# need to restart.
+	    my $deadhost = $ChildHash{$deadchild};
+	    delete($HostToPid{$deadhost});
+	    delete($ChildHash{$deadchild});
+	    Log("WARNING","Lost child pid= ".$deadchild.
+		"Connected to host ".$deadhost);
+	    Log("INFO", "Restarting child procesing ".$deadhost);
+	    CreateChild($deadhost);
+	}
     }
 }
 
 
-
 =pod
 
 =head1 CheckKids