[LON-CAPA-cvs] cvs: loncom(version_2_4_X) /lonnet/perl lonnet.pm
albertel
lon-capa-cvs-allow@mail.lon-capa.org
Mon, 25 Jun 2007 23:31:36 -0000
albertel Mon Jun 25 19:31:36 2007 EDT
Modified files: (Branch: version_2_4_X)
/loncom/lonnet/perl lonnet.pm
Log:
- backport 1.893
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.890.2.1 loncom/lonnet/perl/lonnet.pm:1.890.2.2
--- loncom/lonnet/perl/lonnet.pm:1.890.2.1 Mon Jun 25 19:30:27 2007
+++ loncom/lonnet/perl/lonnet.pm Mon Jun 25 19:31:33 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.890.2.1 2007/06/25 23:30:27 albertel Exp $
+# $Id: lonnet.pm,v 1.890.2.2 2007/06/25 23:31:33 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -7977,6 +7977,7 @@
sub get_iphost {
my ($ignore_cache) = @_;
+
if (!$ignore_cache) {
if (%iphost) {
return %iphost;
@@ -7990,16 +7991,31 @@
return %iphost;
}
}
+
+ # get yesterday's info for fallback
+ my %old_name_to_ip;
+ my ($ip_info,$cached)=
+ &Apache::lonnet::is_cached_new('iphost','iphost');
+ if ($cached) {
+ %old_name_to_ip = %{$ip_info->[1]};
+ }
+
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 name $name no IP found");
- next;
+ if (defined($old_name_to_ip{$name})) {
+ $ip = $old_name_to_ip{$name};
+ &logthis("Can't find $name defaulting to old $ip");
+ } else {
+ &logthis("Name $name no IP found");
+ next;
+ }
+ } else {
+ $ip=inet_ntoa($ip);
}
- $ip=inet_ntoa($ip);
$name_to_ip{$name} = $ip;
} else {
$ip = $name_to_ip{$name};
@@ -8011,7 +8027,7 @@
}
&Apache::lonnet::do_cache_new('iphost','iphost',
[\%iphost,\%name_to_ip,\%lonid_to_ip],
- 24*60*60);
+ 48*60*60);
return %iphost;
}