--- loncom/lonnet/perl/lonnet.pm 2001/01/10 22:55:52 1.94 +++ loncom/lonnet/perl/lonnet.pm 2001/01/11 11:11:27 1.97 @@ -85,7 +85,7 @@ # 05/01/01 Guy Albertelli # 05/01,06/01,09/01 Gerd Kortemeyer # 09/01 Guy Albertelli -# 09/01,10/01 Gerd Kortemeyer +# 09/01,10/01,11/01 Gerd Kortemeyer package Apache::lonnet; @@ -245,17 +245,23 @@ sub appenv { $ENV{$_}=$newenv{$_}; } } keys %newenv; + + my $lockfh; + unless ($lockfh=Apache::File->new("$ENV{'user.environment'}")) { + return 'error: '.$!; + } + unless (flock($lockfh,LOCK_EX)) { + &logthis("WARNING: ". + 'Could not obtain exclusive lock in appenv: '.$!); + $lockfh->close(); + return 'error: '.$!; + } + my @oldenv; { my $fh; unless ($fh=Apache::File->new("$ENV{'user.environment'}")) { - return 'error'; - } - unless (flock($fh,LOCK_SH)) { - &logthis("WARNING: ". - 'Could not obtain shared lock in appenv: '.$!); - $fh->close(); - return 'error: '.$!; + return 'error: '.$!; } @oldenv=<$fh>; $fh->close(); @@ -275,17 +281,13 @@ sub appenv { return 'error'; } my $newname; - unless (flock($fh,LOCK_EX)) { - &logthis("WARNING: ". - 'Could not obtain exclusive lock in appenv: '.$!); - $fh->close(); - return 'error: '.$!; - } foreach $newname (keys %newenv) { print $fh "$newname=$newenv{$newname}\n"; } $fh->close(); } + + $lockfh->close(); return 'ok'; } # ----------------------------------------------------- Delete from Environment @@ -691,8 +693,7 @@ sub coursedescription { if ($chome ne 'no_host') { my $rep=reply("dump:$cdomain:$cnum:environment",$chome); if ($rep ne 'con_lost') { - my $normalid=$courseid; - $normalid=~s/\//\_/g; + my $normalid=$cdomain.'_'.$cnum; my %envhash=(); my %returnhash=('home' => $chome, 'domain' => $cdomain, @@ -1615,7 +1616,6 @@ sub EXT { my $courselevelm= $ENV{'request.course.id'}.'.'.$mapparm; - # ----------------------------------------------------------- first, check user my %resourcedata=get('resourcedata', ($courselevelr,$courselevelm,$courselevel)); @@ -1636,18 +1636,16 @@ sub EXT { ""); } } + # -------------------------------------------------------- second, check course - my $section=''; - if ($ENV{'request.course.sec'}) { - $section='_'.$ENV{'request.course.sec'}; - } + my $reply=&reply('get:'. - $ENV{'course.'.$ENV{'request.course.id'}.$section.'.domain'}.':'. - $ENV{'course.'.$ENV{'request.course.id'}.$section.'.num'}. + $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}.':'. + $ENV{'course.'.$ENV{'request.course.id'}.'.num'}. ':resourcedata:'. &escape($seclevelr).'&'.&escape($seclevelm).'&'.&escape($seclevel).'&'. &escape($courselevelr).'&'.&escape($courselevelm).'&'.&escape($courselevel), - $ENV{'course.'.$ENV{'request.course.id'}.$section.'.home'}); + $ENV{'course.'.$ENV{'request.course.id'}.'.home'}); if ($reply!~/^error\:/) { map { if ($_) { return &unescape($_); } @@ -1655,8 +1653,12 @@ sub EXT { } if (($reply=~/^con_lost/) || ($reply=~/^error\:/)) { &logthis("WARNING:". - " Getting ".$reply." asking for ".$varname." from ". - $ENV{'course.'.$ENV{'request.course.id'}.$section.'.home'}. + " Getting ".$reply." asking for ".$varname." for ". + $ENV{'course.'.$ENV{'request.course.id'}.'.num'}. + ' at '. + $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}. + ' from '. + $ENV{'course.'.$ENV{'request.course.id'}.'.home'}. ""); } # ------------------------------------------------------ third, check map parms