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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 04 Jul 2002 15:47:18 -0000


albertel		Thu Jul  4 11:47:18 2002 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - the logic in the data caching was completely foobar should be fixed now
    my testing saw parameters get invalidated and regotten after a time and
    cached accesses otherwise (BUG#200)
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.249 loncom/lonnet/perl/lonnet.pm:1.250
--- loncom/lonnet/perl/lonnet.pm:1.249	Thu Jun 27 17:11:44 2002
+++ loncom/lonnet/perl/lonnet.pm	Thu Jul  4 11:47:18 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.249 2002/06/27 21:11:44 www Exp $
+# $Id: lonnet.pm,v 1.250 2002/07/04 15:47:18 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2271,30 +2271,34 @@
     my ($coursenum,$coursedomain,@which)=@_;
     my $coursehom=&homeserver($coursenum,$coursedomain);
     my $hashid=$coursenum.':'.$coursedomain;
-    unless (defined($courseresdatacache{$hashid.'.time'})) {
-	unless (time-$courseresdatacache{$hashid.'.time'}<300) {
-           my $coursehom=&homeserver($coursenum,$coursedomain);
-           if ($coursehom) {
-              my $dumpreply=&reply('dump:'.$coursedomain.':'.$coursenum.
-			     ':resourcedata:.',$coursehom);
-	      unless ($dumpreply=~/^error\:/) {
-	         $courseresdatacache{$hashid.'.time'}=time;
-                 $courseresdatacache{$hashid}=$dumpreply;
-	     }
-	  }
-       }
+    my $dodump=0;
+    if (!defined($courseresdatacache{$hashid.'.time'})) {
+	$dodump=1;
+    } else {
+	if (time-$courseresdatacache{$hashid.'.time'}>300) { $dodump=1; }
+    }
+    if ($dodump) {
+	my $coursehom=&homeserver($coursenum,$coursedomain);
+	if ($coursehom) {
+	    my $dumpreply=&reply('dump:'.$coursedomain.':'.$coursenum.
+				 ':resourcedata:.',$coursehom);
+	    if ($dumpreply!~/^error\:/) {
+		$courseresdatacache{$hashid.'.time'}=time;
+		$courseresdatacache{$hashid}=$dumpreply;
+	    }
+	}
+    }
+    my @pairs=split(/\&/,$courseresdatacache{$hashid});
+    my %returnhash=();
+    foreach (@pairs) {
+	my ($key,$value)=split(/=/,$_);
+	$returnhash{unescape($key)}=unescape($value);
     }
-   my @pairs=split(/\&/,$courseresdatacache{$hashid});
-   my %returnhash=();
-   foreach (@pairs) {
-      my ($key,$value)=split(/=/,$_);
-      $returnhash{unescape($key)}=unescape($value);
-   }
     my $item;
-   foreach $item (@which) {
-       if ($returnhash{$item}) { return $returnhash{$item}; }
-   }
-   return '';
+    foreach $item (@which) {
+	if ($returnhash{$item}) { return $returnhash{$item}; }
+    }
+    return '';
 }
 
 # --------------------------------------------------------- Value of a Variable