[LON-CAPA-cvs] cvs: loncom(version_1_2_X) /lonnet/perl lonnet.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Mon, 20 Sep 2004 20:14:15 -0000
albertel Mon Sep 20 16:14:15 2004 EDT
Modified files: (Branch: version_1_2_X)
/loncom/lonnet/perl lonnet.pm
Log:
- backport 1.543 and 1.544
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.523.2.4 loncom/lonnet/perl/lonnet.pm:1.523.2.5
--- loncom/lonnet/perl/lonnet.pm:1.523.2.4 Thu Sep 16 22:41:21 2004
+++ loncom/lonnet/perl/lonnet.pm Mon Sep 20 16:14:14 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.523.2.4 2004/09/17 02:41:21 albertel Exp $
+# $Id: lonnet.pm,v 1.523.2.5 2004/09/20 20:14:14 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -826,6 +826,7 @@
sub devalidate_cache {
my ($cache,$id,$name) = @_;
delete $$cache{$id.'.time'};
+ delete $$cache{$id.'.file'};
delete $$cache{$id};
if (1 || $disk_caching_disabled) { return; }
my $filename=$perlvar{'lonDaemons'}.'/tmp/lonnet_internal_cache_'.$name.".db";
@@ -864,9 +865,25 @@
return (undef,undef);
} else {
if (time-($$cache{$id.'.time'})>$time) {
-# &logthis("Devalidating $id - ".time-($$cache{$id.'.time'}));
- &devalidate_cache($cache,$id,$name);
- return (undef,undef);
+ if (exists($$cache{$id.'.file'})) {
+ foreach my $filename (@{ $$cache{$id.'.file'} }) {
+ my $mtime=(stat($filename))[9];
+ #+1 is to take care of edge effects
+ if ($mtime && (($mtime+1) < ($$cache{$id.'.time'}))) {
+# &logthis("Upping $mtime - ".$$cache{$id.'.time'}.
+# "$id because of $filename");
+ } else {
+ &logthis("Devalidating $filename $id - ".(time-($$cache{$id.'.time'})));
+ &devalidate_cache($cache,$id,$name);
+ return (undef,undef);
+ }
+ }
+ $$cache{$id.'.time'}=time;
+ } else {
+# &logthis("Devalidating $id - ".time-($$cache{$id.'.time'}));
+ &devalidate_cache($cache,$id,$name);
+ return (undef,undef);
+ }
}
}
return ($$cache{$id},1);
@@ -910,6 +927,9 @@
eval <<'EVALBLOCK';
$hash{$id.'.time'}=$$cache{$id.'.time'};
$hash{$id}=freeze({'item'=>$$cache{$id}});
+ if (exists($$cache{$id.'.file'})) {
+ $hash{$id.'.file'}=freeze({'item'=>$$cache{$id.'.file'}});
+ }
EVALBLOCK
if ($@) {
&logthis("<font color='red'>save_cache blew up :$@:$name</font>");
@@ -960,8 +980,14 @@
} else {
if (($$cache{$id.'.time'}+$time) < time) {
$$cache{$id.'.time'}=$hash{$id.'.time'};
- my $hashref=thaw($hash{$id});
- $$cache{$id}=$hashref->{'item'};
+ {
+ my $hashref=thaw($hash{$id});
+ $$cache{$id}=$hashref->{'item'};
+ }
+ if (exists($hash{$id.'.file'})) {
+ my $hashref=thaw($hash{$id.'.file'});
+ $$cache{$id.'.file'}=$hashref->{'item'};
+ }
}
}
EVALBLOCK
@@ -4227,7 +4253,9 @@
unless ($filename=~/\.meta$/) { $filename.='.meta'; }
my $metastring;
if ($uri !~ m|^uploaded/|) {
- $metastring=&getfile(&filelocation('',&clutter($filename)));
+ my $file=&filelocation('',&clutter($filename));
+ push(@{$metacache{$uri.'.file'}},$file);
+ $metastring=&getfile($file);
}
my $parser=HTML::LCParser->new(\$metastring);
my $token;