[LON-CAPA-cvs] cvs: loncom /interface lonindexer.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Mon, 16 Jun 2003 17:27:33 -0000
matthew Mon Jun 16 13:27:33 2003 EDT
Modified files:
/loncom/interface lonindexer.pm
Log:
Bug: 1615. No longer keep hash tied throught network calls. Copy all
of the db file into memory, do the lonindexer stuff, copy it back to the
filesystem. No longer 'untie(%hash)' on errors since the hash is not tied.
Index: loncom/interface/lonindexer.pm
diff -u loncom/interface/lonindexer.pm:1.66 loncom/interface/lonindexer.pm:1.67
--- loncom/interface/lonindexer.pm:1.66 Fri Jun 13 20:15:01 2003
+++ loncom/interface/lonindexer.pm Mon Jun 16 13:27:33 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Directory Indexer
#
-# $Id: lonindexer.pm,v 1.66 2003/06/14 00:15:01 albertel Exp $
+# $Id: lonindexer.pm,v 1.67 2003/06/16 17:27:33 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -84,13 +84,13 @@
# ----------------------------- Handling routine called via Apache and mod_perl
sub handler {
my $r = shift;
+ my $c = $r->connection();
$r->content_type('text/html');
&Apache::loncommon::no_cache($r);
$r->send_http_header;
return OK if $r->header_only;
$fnum=0;
$dnum=0;
- untie %hash;
# Deal with stupid global variables (is there a way around making
# these global to this package? It is just so wrong....)
@@ -125,8 +125,14 @@
$extrafield='';
my $diropendb =
"/home/httpd/perl/tmp/$ENV{'user.domain'}_$ENV{'user.name'}_indexer.db";
+ %hash = ();
+ my %dbfile;
+ if (tie(%dbfile,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) {
+ while(my($key,$value)=each(%dbfile)) {
+ $hash{$key}=$value;
+ }
+ untie(%dbfile);
- if (tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) {
if ($ENV{'form.launch'} eq '1') {
&start_fresh_session();
}
@@ -493,18 +499,27 @@
# --------------------------------------------------- end the output and return
$r->print('</body></html>'."\n");
- untie(%hash);
} else {
$r->print('<html><head></head><body>Unable to tie hash to db '.
'file</body></html>');
return OK;
}
+ if(! $c->aborted()) {
+ if (tie(%dbfile,'GDBM_File',$diropendb,&GDBM_NEWDB(),0640)) {
+ while (my($key,$value) = each(%hash)) {
+ $dbfile{$key}=$value;
+ }
+ untie(%dbfile);
+ }
+ }
+
return OK;
}
# ----------------------------------------------- recursive scan of a directory
sub scanDir {
my ($r,$startdir,$indent,$hashref)=@_;
+ my $c = $r->connection();
my ($compuri,$curdir);
my $dirptr=16384;
$indent++;
@@ -512,6 +527,7 @@
my %dupdirs = %dirs;
my @list=&get_list($r,$startdir);
foreach my $line (@list) {
+ return if ($c->aborted());
my ($strip,$dom,undef,$testdir,undef)=split(/\&/,$line,5);
next if $strip =~ /.*\.meta$/;
my (@fileparts) = split(/\./,$strip);
@@ -948,9 +964,6 @@
sub cleanup {
if (tied(%hash)){
&Apache::lonnet::logthis('Cleanup indexer: hash');
- unless (untie(%hash)) {
- &Apache::lonnet::logthis('Failed cleanup indexer: hash');
- }
}
}