--- loncom/lonnet/perl/lonnet.pm 2003/12/08 13:50:57 1.457 +++ loncom/lonnet/perl/lonnet.pm 2003/12/12 00:20:08 1.459 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.457 2003/12/08 13:50:57 raeburn Exp $ +# $Id: lonnet.pm,v 1.459 2003/12/12 00:20:08 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1319,8 +1319,15 @@ sub flushcourselogs { # Writes to the dynamic metadata of resources to get hit counts, etc. # foreach my $entry (keys(%accesshash)) { - my ($dom,$name,undef,$type)=($entry=~m:___(\w+)/(\w+)/(.*)___(\w+)$:); - if ($type eq 'count'){ + if ($entry =~ /___count$/) { + my ($dom,$name); + ($dom,$name,undef)=($entry=~m:___(\w+)/(\w+)/(.*)___count$:); + if (! defined($dom) || $dom eq '' || + ! defined($name) || $name eq '') { + my $cid = $ENV{'request.course.id'}; + $dom = $ENV{'request.'.$cid.'.domain'}; + $name = $ENV{'request.'.$cid.'.num'}; + } my $value = $accesshash{$entry}; my (undef,$url,undef) = ($entry =~ /^(.*)___(.*)___count$/); my %temphash=($url => $value); @@ -1335,6 +1342,7 @@ sub flushcourselogs { } } } else { + my ($dom,$name) = ($entry=~m:___(\w+)/(\w+)/(.*)___(\w+)$:); my %temphash=($entry => $accesshash{$entry}); if (&put('nohist_resevaldata',\%temphash,$dom,$name) eq 'ok') { delete $accesshash{$entry}; @@ -1375,8 +1383,7 @@ sub courselog { } else { $courselogs{$ENV{'request.course.id'}}.=$what; } -# if (length($courselogs{$ENV{'request.course.id'}})>4048) { - if (length($courselogs{$ENV{'request.course.id'}})>48) { + if (length($courselogs{$ENV{'request.course.id'}})>4048) { &flushcourselogs(); } } @@ -1398,6 +1405,7 @@ sub courseacclog { sub countacc { my $url=&declutter(shift); + return if (! defined($url) || $url eq ''); unless ($ENV{'request.course.id'}) { return ''; } $accesshash{$ENV{'request.course.id'}.'___'.$url.'___course'}=1; my $key=$$.$processmarker.'_'.$dumpcount.'___'.$url.'___count'; @@ -3695,12 +3703,13 @@ sub EXT { if ($$result{$courselevel}) { return $$result{$courselevel}; } } else { - if ($tmp!~/No such file/) { + #error 2 occurs when the .db doesn't exist + if ($tmp!~/error: 2 /) { &logthis("WARNING:". " Trying to get resource data for ". $uname." at ".$udom.": ". $tmp.""); - } elsif ($tmp=~/error:No such file/) { + } elsif ($tmp=~/error: 2 /) { &EXT_cache_set($udom,$uname); } elsif ($tmp =~ /^(con_lost|no_such_host)/) { return $tmp;