version 1.15, 2003/10/28 11:15:10
|
version 1.22, 2004/01/05 09:30:10
|
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 60 sub ReadConfig {
|
Line 67 sub ReadConfig {
|
my $perlvarref = read_conf('loncapa.conf'); |
my $perlvarref = read_conf('loncapa.conf'); |
%perlvar = %{$perlvarref}; |
%perlvar = %{$perlvarref}; |
my $hoststab = read_hosts( |
my $hoststab = read_hosts( |
"$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; |
|
|
} |
} |
|
|
Line 84 sub ReadForeignConfig {
|
Line 92 sub ReadForeignConfig {
|
my $MyHost = shift; |
my $MyHost = shift; |
my $Filename = shift; |
my $Filename = shift; |
|
|
|
&Debug(4, "ReadForeignConfig $MyHost $Filename\n"); |
|
|
$perlvar{lonHostID} = $MyHost; # Rmember my host. |
$perlvar{lonHostID} = $MyHost; # Rmember my host. |
my $hosttab = read_hosts($Filename) || |
my $hosttab = read_hosts($Filename) || |
die "Can't read hosts table!!"; |
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; |
|
|
} |
} |
|
|
Line 112 sub Dump {
|
Line 127 sub Dump {
|
my $self = shift; |
my $self = shift; |
my $key; |
my $key; |
my $value; |
my $value; |
print "Dumping LondConnectionObject:\n"; |
print STDERR "Dumping LondConnectionObject:\n"; |
while(($key, $value) = each %$self) { |
while(($key, $value) = each %$self) { |
print STDERR "$key -> $value\n"; |
print STDERR "$key -> $value\n"; |
} |
} |
Line 176 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 546 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 768 sub read_conf
|
Line 792 sub read_conf
|
my %perlvar; |
my %perlvar; |
foreach my $filename (@conf_files,'loncapa_apache.conf') |
foreach my $filename (@conf_files,'loncapa_apache.conf') |
{ |
{ |
|
if($DebugLevel > 3) { |
|
print("Going to read $confdir.$filename\n"); |
|
} |
open(CONFIG,'<'.$confdir.$filename) or |
open(CONFIG,'<'.$confdir.$filename) or |
die("Can't read $confdir$filename"); |
die("Can't read $confdir$filename"); |
while (my $configline=<CONFIG>) |
while (my $configline=<CONFIG>) |
Line 781 sub read_conf
|
Line 808 sub read_conf
|
} |
} |
close(CONFIG); |
close(CONFIG); |
} |
} |
|
if($DebugLevel > 3) { |
|
print "Dumping perlvar:\n"; |
|
foreach my $var (keys %perlvar) { |
|
print "$var = $perlvar{$var}\n"; |
|
} |
|
} |
my $perlvarref=\%perlvar; |
my $perlvarref=\%perlvar; |
return ($perlvarref); |
return $perlvarref; |
} |
} |
|
|
#---------------------- Subroutine read_hosts: Read a LON-CAPA hosts.tab |
#---------------------- Subroutine read_hosts: Read a LON-CAPA hosts.tab |
# formatted configuration file. |
# formatted configuration file. |
Line 797 sub read_hosts {
|
Line 830 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); |