[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm

matthew lon-capa-cvs@mail.lon-capa.org
Thu, 16 May 2002 20:25:12 -0000


matthew		Thu May 16 16:25:12 2002 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  Fix bug 441, &Apache::lonnet::homeserver now caches negative results.
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.220 loncom/lonnet/perl/lonnet.pm:1.221
--- loncom/lonnet/perl/lonnet.pm:1.220	Thu May 16 13:21:05 2002
+++ loncom/lonnet/perl/lonnet.pm	Thu May 16 16:25:12 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.220 2002/05/16 17:21:05 harris41 Exp $
+# $Id: lonnet.pm,v 1.221 2002/05/16 20:25:12 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -77,7 +77,7 @@
 use LWP::UserAgent();
 use HTTP::Headers;
 use vars 
-qw(%perlvar %hostname %homecache %hostip %spareid %hostdom 
+qw(%perlvar %hostname %homecache %badhomecache %hostip %spareid %hostdom 
    %libserv %pr %prp %metacache %packagetab 
    %courselogs %accesshash $processmarker $dumpcount 
    %coursedombuf %coursehombuf %courseresdatacache);
@@ -482,18 +482,24 @@
 
 sub homeserver {
     my ($uname,$udom)=@_;
-
     my $index="$uname:$udom";
-    if ($homecache{$index}) { return "$homecache{$index}"; }
-
+    if ($homecache{$index}) { 
+        return "$homecache{$index}"; 
+    }
     my $tryserver;
     foreach $tryserver (keys %libserv) {
+        next if (exists($badhomecache{$index}->{$tryserver}));
 	if ($hostdom{$tryserver} eq $udom) {
            my $answer=reply("home:$udom:$uname",$tryserver);
+           my @tmp =keys(%{$badhomecache{$index}}); 
            if ($answer eq 'found') { 
-	      $homecache{$index}=$tryserver;
+              $homecache{$index}=$tryserver;
               return $tryserver; 
-	   }
+           } else {
+               $badhomecache{$index}->{$tryserver}=1;
+           }
+       } else {
+           $badhomecache{$index}->{$tryserver}=1;
        }
     }    
     return 'no_host';