--- loncom/loncnew 2003/09/16 09:46:42 1.24 +++ loncom/loncnew 2003/09/30 11:11:17 1.26 @@ -2,7 +2,7 @@ # The LearningOnline Network with CAPA # lonc maintains the connections to remote computers # -# $Id: loncnew,v 1.24 2003/09/16 09:46:42 foxr Exp $ +# $Id: loncnew,v 1.26 2003/09/30 11:11:17 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -45,6 +45,14 @@ # Change log: # $Log: loncnew,v $ +# Revision 1.26 2003/09/30 11:11:17 foxr +# Add book-keeping hashes to support the re-init procedure. +# +# Revision 1.25 2003/09/23 11:22:14 foxr +# Tested ability to receive sigusr2 This is now logged and must be +# properly implemented as a re-read of hosts and re-init of appropriate +# children. +# # Revision 1.24 2003/09/16 09:46:42 foxr # Added skeletal infrastructure to support SIGUSR2 update hosts request. # @@ -144,12 +152,6 @@ use LONCAPA::HashIterator; # # Disable all signals we might receive from outside for now. # -#$SIG{QUIT} = IGNORE; -#$SIG{HUP} = IGNORE; -#$SIG{USR1} = IGNORE; -#$SIG{INT} = IGNORE; -#$SIG{CHLD} = IGNORE; -#$SIG{__DIE__} = IGNORE; # Read the httpd configuration file to get perl variables @@ -162,6 +164,8 @@ my %perlvar = %{$perlvarref}; # parent and shared variables. my %ChildHash; # by pid -> host. +my %HostToPid; # By host -> pid. +my %HostHash; # by loncapaname -> IP. my $MaxConnectionCount = 10; # Will get from config later. @@ -1521,6 +1525,7 @@ sub CreateChild { if($pid) { # Parent $RemoteHost = "Parent"; $ChildHash{$pid} = $RemoteHost; + $HostToPid{$host}= $pid; sigprocmask(SIG_UNBLOCK, $sigset); } else { # child. @@ -1583,6 +1588,7 @@ while (! $HostIterator->end()) { my $hostentryref = $HostIterator->get(); CreateChild($hostentryref->[0]); + $HostHash{$hostentryref->[0]} = $hostentryref->[4]; $HostIterator->next(); } $RemoteHost = "Parent Server"; @@ -1605,6 +1611,7 @@ 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); @@ -1645,7 +1652,7 @@ sub CheckKids { =head1 UpdateKids -parent's SIGUSR1 handler. This handler: +parent's SIGUSR2 handler. This handler: =item @@ -1668,6 +1675,7 @@ the start of the master program and main =cut sub UpdateKids { + Log("INFO", "Updating connections via SIGUSR2"); }