--- loncom/LondConnection.pm 2003/10/28 11:15:10 1.15 +++ loncom/LondConnection.pm 2003/12/08 20:32:17 1.19 @@ -1,7 +1,7 @@ # This module defines and implements a class that represents # a connection to a lond daemon. # -# $Id: LondConnection.pm,v 1.15 2003/10/28 11:15:10 foxr Exp $ +# $Id: LondConnection.pm,v 1.19 2003/12/08 20:32:17 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -46,6 +46,13 @@ my %hostshash; my %perlvar; # +# Set debugging level +# +sub SetDebug { + $DebugLevel = shift; +} + +# # The config read is done in this way to support the read of # the non-default configuration file in the # event we are being used outside of loncapa. @@ -63,6 +70,7 @@ sub ReadConfig { "$perlvar{'lonTabDir'}/hosts.tab") || die "Can't read host table!!"; %hostshash = %{$hoststab}; + $ConfigRead = 1; } @@ -84,11 +92,18 @@ sub ReadForeignConfig { my $MyHost = shift; my $Filename = shift; + &Debug(4, "ReadForeignConfig $MyHost $Filename\n"); + $perlvar{lonHostID} = $MyHost; # Rmember my host. my $hosttab = read_hosts($Filename) || die "Can't read hosts table!!"; - %hostshash = %{$hosttab} - + %hostshash = %{$hosttab}; + if($DebugLevel > 3) { + foreach my $host (keys %hostshash) { + print "host $host => $hostshash{$host}\n"; + } + } + $ConfigRead = 1; } @@ -114,7 +129,7 @@ sub Dump { my $value; print "Dumping LondConnectionObject:\n"; while(($key, $value) = each %$self) { - print STDERR "$key -> $value\n"; + print "$key -> $value\n"; } print "-------------------------------\n"; } @@ -176,6 +191,7 @@ sub new { # LoncapaHim fields of the object respectively. # if (!exists $hostshash{$Hostname}) { + &Debug(8, "No Such host $Hostname"); return undef; # No such host!!! } my @ConfigLine = @{$hostshash{$Hostname}}; @@ -546,6 +562,8 @@ Shuts down the socket. sub Shutdown { my $self = shift; my $socket = $self->GetSocket(); + $socket->send("exit\n", 0); # Ask lond to exit too. Non blocking so + # there's no cost for failure. $socket->shutdown(2); } @@ -797,7 +815,7 @@ sub read_hosts { my $Filename = shift; my %HostsTab; - open(CONFIG,'<'.$Filename) or die("Can't read $Filename"); + open(CONFIG,'<'.$Filename) or die("Can't read $Filename"); while (my $line = ) { if (!($line =~ /^\s*\#/)) { my @items = split(/:/, $line);