[LON-CAPA-cvs] cvs: loncom(version_1_2_X) /lonnet/perl lonnet.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Fri, 17 Sep 2004 02:41:22 -0000
albertel Thu Sep 16 22:41:22 2004 EDT
Modified files: (Branch: version_1_2_X)
/loncom/lonnet/perl lonnet.pm
Log:
- backport 1.542
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.523.2.3 loncom/lonnet/perl/lonnet.pm:1.523.2.4
--- loncom/lonnet/perl/lonnet.pm:1.523.2.3 Wed Sep 15 16:44:05 2004
+++ loncom/lonnet/perl/lonnet.pm Thu Sep 16 22:41:21 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.523.2.3 2004/09/15 20:44:05 albertel Exp $
+# $Id: lonnet.pm,v 1.523.2.4 2004/09/17 02:41:21 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -857,7 +857,7 @@
my ($cache,$id,$name,$time) = @_;
if (!$time) { $time=300; }
if (!exists($$cache{$id.'.time'})) {
- &load_cache_item($cache,$name,$id);
+ &load_cache_item($cache,$name,$id,$time);
}
if (!exists($$cache{$id.'.time'})) {
# &logthis("Didn't find $id");
@@ -934,7 +934,7 @@
}
sub load_cache_item {
- my ($cache,$name,$id)=@_;
+ my ($cache,$name,$id,$time)=@_;
if ($disk_caching_disabled) { return; }
my $starttime=&Time::HiRes::time();
# &logthis("Before Loading $name for $id size is ".scalar(%$cache));
@@ -958,9 +958,11 @@
}
# &logthis("Initial load: $count");
} else {
- my $hashref=thaw($hash{$id});
- $$cache{$id}=$hashref->{'item'};
- $$cache{$id.'.time'}=$hash{$id.'.time'};
+ if (($$cache{$id.'.time'}+$time) < time) {
+ $$cache{$id.'.time'}=$hash{$id.'.time'};
+ my $hashref=thaw($hash{$id});
+ $$cache{$id}=$hashref->{'item'};
+ }
}
EVALBLOCK
if ($@) {
@@ -4590,22 +4592,19 @@
sub symbread {
my ($thisfn,$donotrecurse)=@_;
- if (defined($ENV{'request.symbread.cached'})) {
- return $ENV{'request.symbread.cached'};
- }
+ my $cache_str='request.symbread.cached.'.$thisfn;
+ if (defined($ENV{$cache_str})) { return $ENV{$cache_str}; }
# no filename provided? try from environment
unless ($thisfn) {
if ($ENV{'request.symb'}) {
- $ENV{'request.symbread.cached'}=&symbclean($ENV{'request.symb'});
- return $ENV{'request.symbread.cached'};
+ return $ENV{$cache_str}=&symbclean($ENV{'request.symb'});
}
$thisfn=$ENV{'request.filename'};
}
# is that filename actually a symb? Verify, clean, and return
if ($thisfn=~/\_\_\_\d+\_\_\_(.*)$/) {
if (&symbverify($thisfn,$1)) {
- $ENV{'request.symbread.cached'}=&symbclean($thisfn);
- return $ENV{'request.symbread.cached'};
+ return $ENV{$cache_str}=&symbclean($thisfn);
}
}
$thisfn=declutter($thisfn);
@@ -4627,8 +4626,7 @@
unless ($syval=~/\_\d+$/) {
unless ($ENV{'form.request.prefix'}=~/\.(\d+)\_$/) {
&appenv('request.ambiguous' => $thisfn);
- $ENV{'request.symbread.cached'}='';
- return '';
+ return $ENV{$cache_str}='';
}
$syval.=$1;
}
@@ -4675,13 +4673,11 @@
}
}
if ($syval) {
- $ENV{'request.symbread.cached'}=&symbclean($syval.'___'.$thisfn);
- return $ENV{'request.symbread.cached'};
+ return $ENV{$cache_str}=&symbclean($syval.'___'.$thisfn);
}
}
&appenv('request.ambiguous' => $thisfn);
- $ENV{'request.symbread.cached'}='';
- return '';
+ return $ENV{$cache_str}='';
}
# ---------------------------------------------------------- Return random seed