--- loncom/loncnew 2005/01/19 21:38:25 1.57.2.1 +++ loncom/loncnew 2004/09/22 10:34:44 1.58 @@ -2,7 +2,7 @@ # The LearningOnline Network with CAPA # lonc maintains the connections to remote computers # -# $Id: loncnew,v 1.57.2.1 2005/01/19 21:38:25 albertel Exp $ +# $Id: loncnew,v 1.58 2004/09/22 10:34:44 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -61,7 +61,6 @@ use LONCAPA::LondConnection; use LONCAPA::LondTransaction; use LONCAPA::Configuration; use LONCAPA::HashIterator; -use Fcntl qw(:flock); # Read the httpd configuration file to get perl variables @@ -384,7 +383,6 @@ sub Tick { $KeyMode = ""; $clock_watcher->cancel(); } - &UpdateStatus(); } =pod @@ -1397,10 +1395,20 @@ sub NewClient { Returns the name of the UNIX socket on which to listen for client connections. +=head2 Parameters: + + host (optional) - Name of the host socket to return.. defaults to + the return from GetServerHost(). + =cut sub GetLoncSocketPath { - return $UnixSocketDir."/".GetServerHost(); + + my $host = GetServerHost(); # Default host. + if (@_) { + ($host) = @_; # Override if supplied. + } + return $UnixSocketDir."/".$host; } =pod @@ -1437,12 +1445,21 @@ connection. The event handler establish (creating a communcations channel), that int turn will establish another event handler to subess requests. +=head2 Parameters: + + host (optional) Name of the host to set up a unix socket to. + =cut sub SetupLoncListener { + my $host = GetServerHost(); # Default host. + if (@_) { + ($host) = @_ # Override host with parameter. + } + my $socket; - my $SocketName = GetLoncSocketPath(); + my $SocketName = GetLoncSocketPath($host); unlink($SocketName); unless ($socket =IO::Socket::UNIX->new(Local => $SocketName, Listen => 250, @@ -1490,29 +1507,25 @@ sub ChildStatus { Debug(2, "Reporting child status because : ".$watcher->data); my $docdir = $perlvar{'lonDocRoot'}; - - open(LOG,">>$docdir/lon-status/loncstatus.txt"); - flock(LOG,LOCK_EX); - print LOG $$."\t".$RemoteHost."\t".$Status."\t". + my $fh = IO::File->new(">>$docdir/lon-status/loncstatus.txt"); + print $fh $$."\t".$RemoteHost."\t".$Status."\t". $RecentLogEntry."\n"; # # Write out information about each of the connections: # if ($DebugLevel > 2) { - print LOG "Active connection statuses: \n"; + print $fh "Active connection statuses: \n"; my $i = 1; print STDERR "================================= Socket Status Dump:\n"; foreach my $item (keys %ActiveConnections) { my $Socket = $ActiveConnections{$item}->data; my $state = $Socket->GetState(); - print LOG "Connection $i State: $state\n"; + print $fh "Connection $i State: $state\n"; print STDERR "---------------------- Connection $i \n"; $Socket->Dump(-1); # Ensure it gets dumped.. $i++; } } - flock(LOG,LOCK_UN); - close(LOG); $ConnectionRetriesLeft = $ConnectionRetries; } @@ -1735,6 +1748,7 @@ sub CheckKids { foreach my $pid (keys %ChildHash) { Debug(2, "Sending USR1 -> $pid"); kill 'USR1' => $pid; # Tell Child to report status. + sleep 1; # Wait so file doesn't intermix. } }