version 1.852, 2007/03/28 00:12:58
|
version 1.857, 2007/04/03 00:49:14
|
Line 145 sub logperm {
|
Line 145 sub logperm {
|
} |
} |
|
|
sub create_connection { |
sub create_connection { |
my ($server) = @_; |
my ($hostname,$lonid) = @_; |
my $client=IO::Socket::UNIX->new(Peer => $perlvar{'lonSockCreate'}, |
my $client=IO::Socket::UNIX->new(Peer => $perlvar{'lonSockCreate'}, |
Type => SOCK_STREAM, |
Type => SOCK_STREAM, |
Timeout => 10); |
Timeout => 10); |
return 0 if (!$client); |
return 0 if (!$client); |
print $client ("$server\n"); |
print $client (join(':',$hostname,$lonid,&machine_ids($lonid))."\n"); |
my $result = <$client>; |
my $result = <$client>; |
chomp($result); |
chomp($result); |
return 1 if ($result eq 'done'); |
return 1 if ($result eq 'done'); |
Line 185 sub subreply {
|
Line 185 sub subreply {
|
if($client) { |
if($client) { |
last; # Connected! |
last; # Connected! |
} else { |
} else { |
&create_connection(&hostname($server)); |
&create_connection(&hostname($server),$server); |
} |
} |
sleep(1); # Try again later if failed connection. |
sleep(1); # Try again later if failed connection. |
} |
} |
Line 7426 sub hreflocation {
|
Line 7426 sub hreflocation {
|
} |
} |
|
|
sub current_machine_domains { |
sub current_machine_domains { |
my $hostname=&hostname($perlvar{'lonHostID'}); |
return &machine_domains(&hostname($perlvar{'lonHostID'})); |
|
} |
|
|
|
sub machine_domains { |
|
my ($hostname) = @_; |
my @domains; |
my @domains; |
my %hostname = &all_hostnames(); |
my %hostname = &all_hostnames(); |
while( my($id, $name) = each(%hostname)) { |
while( my($id, $name) = each(%hostname)) { |
Line 7439 sub current_machine_domains {
|
Line 7443 sub current_machine_domains {
|
} |
} |
|
|
sub current_machine_ids { |
sub current_machine_ids { |
my $hostname=&hostname($perlvar{'lonHostID'}); |
return &machine_ids(&hostname($perlvar{'lonHostID'})); |
|
} |
|
|
|
sub machine_ids { |
|
my ($hostname) = @_; |
|
$hostname ||= &hostname($perlvar{'lonHostID'}); |
my @ids; |
my @ids; |
my %hostname = &all_hostnames(); |
my %hostname = &all_hostnames(); |
while( my($id, $name) = each(%hostname)) { |
while( my($id, $name) = each(%hostname)) { |
Line 7580 sub goodbye {
|
Line 7589 sub goodbye {
|
} |
} |
|
|
BEGIN { |
BEGIN { |
|
|
# ----------------------------------- Read loncapa.conf and loncapa_apache.conf |
# ----------------------------------- Read loncapa.conf and loncapa_apache.conf |
unless ($readit) { |
unless ($readit) { |
{ |
{ |
Line 7752 sub get_dns {
|
Line 7762 sub get_dns {
|
|
|
{ |
{ |
my %iphost; |
my %iphost; |
|
my %name_to_ip; |
|
my %lonid_to_ip; |
sub get_hosts_from_ip { |
sub get_hosts_from_ip { |
my ($ip) = @_; |
my ($ip) = @_; |
my %iphosts = &get_iphost(); |
my %iphosts = &get_iphost(); |
Line 7760 sub get_dns {
|
Line 7772 sub get_dns {
|
} |
} |
return; |
return; |
} |
} |
|
|
|
sub get_host_ip { |
|
my ($lonid) = @_; |
|
if (exists($lonid_to_ip{$lonid})) { |
|
return $lonid_to_ip{$lonid}; |
|
} |
|
my $name=&hostname($lonid); |
|
my $ip = gethostbyname($name); |
|
return if (!$ip || length($ip) ne 4); |
|
$ip=inet_ntoa($ip); |
|
$name_to_ip{$name} = $ip; |
|
$lonid_to_ip{$lonid} = $ip; |
|
return $ip; |
|
} |
|
|
sub get_iphost { |
sub get_iphost { |
if (%iphost) { return %iphost; } |
if (%iphost) { return %iphost; } |
my %name_to_ip; |
|
my %hostname = &all_hostnames(); |
my %hostname = &all_hostnames(); |
foreach my $id (keys(%hostname)) { |
foreach my $id (keys(%hostname)) { |
my $name=$hostname{$id}; |
my $name=$hostname{$id}; |
Line 7779 sub get_dns {
|
Line 7804 sub get_dns {
|
} else { |
} else { |
$ip = $name_to_ip{$name}; |
$ip = $name_to_ip{$name}; |
} |
} |
|
$lonid_to_ip{$id} = $ip; |
push(@{$iphost{$ip}},$id); |
push(@{$iphost{$ip}},$id); |
} |
} |
return %iphost; |
return %iphost; |