version 1.14, 2003/10/28 10:47:44
|
version 1.20, 2003/12/11 23:16:06
|
Line 46 my %hostshash;
|
Line 46 my %hostshash;
|
my %perlvar; |
my %perlvar; |
|
|
# |
# |
|
# Set debugging level |
|
# |
|
sub SetDebug { |
|
$DebugLevel = shift; |
|
} |
|
|
|
# |
# The config read is done in this way to support the read of |
# The config read is done in this way to support the read of |
# the non-default configuration file in the |
# the non-default configuration file in the |
# event we are being used outside of loncapa. |
# event we are being used outside of loncapa. |
Line 63 sub ReadConfig {
|
Line 70 sub ReadConfig {
|
"$perlvar{'lonTabDir'}/hosts.tab") || |
"$perlvar{'lonTabDir'}/hosts.tab") || |
die "Can't read host table!!"; |
die "Can't read host table!!"; |
%hostshash = %{$hoststab}; |
%hostshash = %{$hoststab}; |
|
$ConfigRead = 1; |
|
|
close(CONFIG); |
|
} |
} |
|
|
|
# |
|
# Read a foreign configuration. |
|
# This sub is intended for the cases where the package |
|
# will be read from outside the LonCAPA environment, in that case |
|
# the client will need to explicitly provide: |
|
# - A file in hosts.tab format. |
|
# - Some idea of the 'lonCAPA' name of the local host (for building |
|
# the encryption key). |
|
# |
|
# Parameters: |
|
# MyHost - Name of this host as far as LonCAPA is concerned. |
|
# Filename - Name of a hosts.tab formatted file that will be used |
|
# to build up the hosts table. |
|
# |
|
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}; |
|
if($DebugLevel > 3) { |
|
foreach my $host (keys %hostshash) { |
|
print "host $host => $hostshash{$host}\n"; |
|
} |
|
} |
|
$ConfigRead = 1; |
|
|
|
} |
|
|
sub Debug { |
sub Debug { |
my $level = shift; |
my $level = shift; |
Line 91 sub Dump {
|
Line 129 sub Dump {
|
my $value; |
my $value; |
print "Dumping LondConnectionObject:\n"; |
print "Dumping LondConnectionObject:\n"; |
while(($key, $value) = each %$self) { |
while(($key, $value) = each %$self) { |
print STDERR "$key -> $value\n"; |
print "$key -> $value\n"; |
} |
} |
print "-------------------------------\n"; |
print "-------------------------------\n"; |
} |
} |
Line 153 sub new {
|
Line 191 sub new {
|
# LoncapaHim fields of the object respectively. |
# LoncapaHim fields of the object respectively. |
# |
# |
if (!exists $hostshash{$Hostname}) { |
if (!exists $hostshash{$Hostname}) { |
|
&Debug(8, "No Such host $Hostname"); |
return undef; # No such host!!! |
return undef; # No such host!!! |
} |
} |
my @ConfigLine = @{$hostshash{$Hostname}}; |
my @ConfigLine = @{$hostshash{$Hostname}}; |
Line 523 Shuts down the socket.
|
Line 562 Shuts down the socket.
|
sub Shutdown { |
sub Shutdown { |
my $self = shift; |
my $self = shift; |
my $socket = $self->GetSocket(); |
my $socket = $self->GetSocket(); |
$socket->shutdown(2); |
Debug(5,"socket is -$socket-"); |
|
if ($socket) { |
|
# Ask lond to exit too. Non blocking so |
|
# there is no cost for failure. |
|
eval { |
|
$socket->send("exit\n", 0); |
|
$socket->shutdown(2); |
|
} |
|
} |
} |
} |
|
|
=pod |
=pod |
Line 774 sub read_hosts {
|
Line 821 sub read_hosts {
|
my $Filename = shift; |
my $Filename = shift; |
my %HostsTab; |
my %HostsTab; |
|
|
open(CONFIG,'<'.$Filename) or die("Can't read $Filename"); |
open(CONFIG,'<'.$Filename) or die("Can't read $Filename"); |
while (my $line = <CONFIG>) { |
while (my $line = <CONFIG>) { |
if (!($line =~ /^\s*\#/)) { |
if (!($line =~ /^\s*\#/)) { |
my @items = split(/:/, $line); |
my @items = split(/:/, $line); |