[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm
albertel
lon-capa-cvs-allow@mail.lon-capa.org
Wed, 13 Jun 2007 01:43:54 -0000
albertel Tue Jun 12 21:43:54 2007 EDT
Modified files:
/loncom/lonnet/perl lonnet.pm
Log:
- was forgetting order of hostids as they occurred in the hosts.tab file
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.887 loncom/lonnet/perl/lonnet.pm:1.888
--- loncom/lonnet/perl/lonnet.pm:1.887 Mon Jun 11 15:31:41 2007
+++ loncom/lonnet/perl/lonnet.pm Tue Jun 12 21:43:54 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.887 2007/06/11 19:31:41 albertel Exp $
+# $Id: lonnet.pm,v 1.888 2007/06/13 01:43:54 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -7600,14 +7600,8 @@
my ($hostname) = @_;
$hostname ||= &hostname($perlvar{'lonHostID'});
my @ids;
- my %hostname = &all_hostnames();
- while( my($id, $name) = each(%hostname)) {
-# &logthis("-$id-$name-$hostname-");
- if ($hostname eq $name) {
- push(@ids,$id);
- }
- }
- return @ids;
+ my %name_to_host = &all_names();
+ return @{ $name_to_host{$hostname} };
}
sub additional_machine_domains {
@@ -7720,6 +7714,7 @@
sub goodbye {
&logthis("Starting Shut down");
+ &logthis("test");
#not converted to using infrastruture and probably shouldn't be
&logthis(sprintf("%-20s is %s",'%badServerCache',length(&nfreeze(\%badServerCache))));
#converted
@@ -7835,6 +7830,7 @@
my %hostdom;
my %libserv;
my $loaded;
+ my %name_to_host;
sub parse_hosts_tab {
my ($file) = @_;
@@ -7846,6 +7842,7 @@
$name=~s/\s//g;
if ($id && $domain && $role && $name) {
$hostname{$id}=$name;
+ push(@{$name_to_host{$name}}, $id);
$hostdom{$id}=$domain;
if ($role eq 'library') { $libserv{$id}=$name; }
}
@@ -7884,6 +7881,12 @@
return %hostname;
}
+ sub all_names {
+ &load_hosts_tab() if (!$loaded);
+
+ return %name_to_host;
+ }
+
sub is_library {
&load_hosts_tab() if (!$loaded);
@@ -8002,14 +8005,13 @@
return %iphost;
}
}
- my %hostname = &all_hostnames();
- foreach my $id (keys(%hostname)) {
- my $name=&hostname($id);
+ my %name_to_host = &all_names();
+ foreach my $name (keys(%name_to_host)) {
my $ip;
if (!exists($name_to_ip{$name})) {
$ip = gethostbyname($name);
if (!$ip || length($ip) ne 4) {
- &logthis("Skipping host $id name $name no IP found");
+ &logthis("Skipping name $name no IP found");
next;
}
$ip=inet_ntoa($ip);
@@ -8017,8 +8019,10 @@
} else {
$ip = $name_to_ip{$name};
}
- $lonid_to_ip{$id} = $ip;
- push(@{$iphost{$ip}},$id);
+ foreach my $id (@{ $name_to_host{$name} }) {
+ $lonid_to_ip{$id} = $ip;
+ }
+ push(@{$iphost{$ip}},@{$name_to_host{$name}});
}
&Apache::lonnet::do_cache_new('iphost','iphost',
[\%iphost,\%name_to_ip,\%lonid_to_ip],