Diff for /rat/lonuserstate.pm between versions 1.132 and 1.133

version 1.132, 2009/11/15 14:08:53 version 1.133, 2009/11/15 21:31:23
Line 645  sub readmap { Line 645  sub readmap {
     my $uri;      my $uri;
     $short=~s/\//\_/g;      $short=~s/\//\_/g;
     unless ($uri=$cenv{'url'}) {       unless ($uri=$cenv{'url'}) { 
  &Apache::lonnet::logthis("<font color=blue>WARNING: ".   &Apache::lonnet::logthis('<font color="blue">WARNING: '.
  "Could not load course $short.</font>");    "Could not load course $short.</font>"); 
  return ('',&mt('No course data available.'));;   return ('',&mt('No course data available.'));;
     }      }
     @cond=('true:normal');      @cond=('true:normal');
   
     open(LOCKFILE,">$fn.db.lock");      unless (open(LOCKFILE,">$fn.db.lock")) {
           $errtext.='<br />'.&mt('Map not loaded - Lock file could not be opened when reading map:').' <tt>'.$fn.'</tt>.';
           $retfurl = '';
           return ($retfurl,$errtext);
       }
     my $lock=0;      my $lock=0;
     my $gotstate=0;      my $gotstate=0;
     if (flock(LOCKFILE,LOCK_EX|LOCK_NB)) {      if (flock(LOCKFILE,LOCK_EX|LOCK_NB)) {
Line 685  sub readmap { Line 689  sub readmap {
             }              }
         }          }
  flock(LOCKFILE,LOCK_UN);   flock(LOCKFILE,LOCK_UN);
  close(LOCKFILE);  
     }      }
     unless ($lock && $tiedhash && $tiedparmhash) {       unless ($lock && $tiedhash && $tiedparmhash) { 
  # if we are here it is likely because we are already trying to    # if we are here it is likely because we are already trying to 
Line 708  sub readmap { Line 711  sub readmap {
                 untie(%parmhash);                  untie(%parmhash);
             }              }
         }          }
  &Apache::lonnet::logthis("<font color=blue>WARNING: ".   &Apache::lonnet::logthis('<font color="blue">WARNING: '.
  "Could not tie coursemap $fn for $uri.</font>");   "Could not tie coursemap $fn for $uri.</font>");
         $tiedhash = '';          $tiedhash = '';
         $tiedparmhash = '';          $tiedparmhash = '';
Line 740  sub readmap { Line 743  sub readmap {
  }   }
         if ($lock) {          if ($lock) {
             flock(LOCKFILE,LOCK_UN);              flock(LOCKFILE,LOCK_UN);
               $lock = 0;
             if ($tiedparmhash) {              if ($tiedparmhash) {
                 unless ($untiedparmhash) {                  unless ($untiedparmhash) {
                     &Apache::lonnet::logthis('<font color="blue">WARNING: '.                      &Apache::lonnet::logthis('<font color="blue">WARNING: '.
Line 755  sub readmap { Line 759  sub readmap {
         }          }
     }      }
     unless ($gotstate) {      unless ($gotstate) {
           $lock = 0;
         &Apache::lonnet::logthis('<font color="blue">WARNING: '.          &Apache::lonnet::logthis('<font color="blue">WARNING: '.
                      'Could not read statemap '.$fn.' for '.$uri.'.</font>');                       'Could not read statemap '.$fn.' for '.$uri.'.</font>');
         &unlink_tmpfiles($fn);          &unlink_tmpfiles($fn);
         if (open(LOCKFILE,">$fn.db.lock")) {          if (flock(LOCKFILE,LOCK_EX|LOCK_NB)) {
             my $lock=0;              $lock=1;
             if (flock(LOCKFILE,LOCK_EX|LOCK_NB)) {          }
                 $lock=1;          undef %randompick;
                 &unlink_tmpfiles($fn);          undef %hiddenurl;
             }          undef %encurl;
             undef %randompick;          $retfrid='';
             undef %hiddenurl;          if ($lock) {
             undef %encurl;              if (tie(%hash,'GDBM_File',"$fn.db",&GDBM_WRCREAT(),0640)) {
             $retfrid='';                  if (tie(%parmhash,'GDBM_File',$fn.'_parms.db',&GDBM_WRCREAT(),0640)) {
             if ($lock) {                      $gotstate = &build_tmp_hashes($uri,$fn,$short,\%cenv);
                 if (tie(%hash,'GDBM_File',"$fn.db",&GDBM_WRCREAT(),0640)) {                      unless ($gotstate) {
                     if (tie(%parmhash,'GDBM_File',$fn.'_parms.db',&GDBM_WRCREAT(),0640)) {  
                         $gotstate = &build_tmp_hashes($uri,$fn,$short,\%cenv);  
                         unless ($gotstate) {  
                             &Apache::lonnet::logthis('<font color="blue">WARNING: '.  
                                 'Failed to write statemap at second attempt '.$fn.' for '.$uri.'.</font>');  
                         }  
                         unless (untie(%parmhash)) {  
                             &Apache::lonnet::logthis('<font color="blue">WARNING: '.  
                                 'Could not untie coursemap parmhash '.$fn.'.db for '.$uri.'.</font>');  
                         }  
                     } else {  
                         &Apache::lonnet::logthis('<font color="blue">WARNING: '.                          &Apache::lonnet::logthis('<font color="blue">WARNING: '.
                             'Could not tie coursemap '.$fn.'__parms.db for '.$uri.'.</font>');                              'Failed to write statemap at second attempt '.$fn.' for '.$uri.'.</font>');
                     }                      }
                     unless (untie(%hash)) {                      unless (untie(%parmhash)) {
                         &Apache::lonnet::logthis('<font color="blue">WARNING: '.                          &Apache::lonnet::logthis('<font color="blue">WARNING: '.
                             'Could not untie coursemap hash '.$fn.'.db for '.$uri.'.</font>');                              'Could not untie coursemap parmhash '.$fn.'.db for '.$uri.'.</font>');
                     }                      }
                } else {                  } else {
                    &Apache::lonnet::logthis('<font color="blue">WARNING: '.                      &Apache::lonnet::logthis('<font color="blue">WARNING: '.
                        'Could not tie coursemap '.$fn.'.db for '.$uri.'.</font>');                          'Could not tie coursemap '.$fn.'__parms.db for '.$uri.'.</font>');
                }                  }
                flock(LOCKFILE,LOCK_UN);                  unless (untie(%hash)) {
                close(LOCKFILE);                      &Apache::lonnet::logthis('<font color="blue">WARNING: '.
                           'Could not untie coursemap hash '.$fn.'.db for '.$uri.'.</font>');
                   }
             } else {              } else {
                 &Apache::lonnet::logthis('<font color="blue">WARNING: '.                 &Apache::lonnet::logthis('<font color="blue">WARNING: '.
                 'Could not obtain lock to tie coursemap hash '.$fn.'.db for '.$uri.'.</font>');                     'Could not tie coursemap '.$fn.'.db for '.$uri.'.</font>');
             }              }
     close(LOCKFILE);              flock(LOCKFILE,LOCK_UN);
               $lock = 0;
           } else {
               &Apache::lonnet::logthis('<font color="blue">WARNING: '.
               'Could not obtain lock to tie coursemap hash '.$fn.'.db for '.$uri.'.</font>');
         }          }
     }      }
       close(LOCKFILE);
     unless (($errtext eq '') || ($env{'request.course.uri'} =~ m{^/uploaded/})) {      unless (($errtext eq '') || ($env{'request.course.uri'} =~ m{^/uploaded/})) {
         &Apache::lonmsg::author_res_msg($env{'request.course.uri'},          &Apache::lonmsg::author_res_msg($env{'request.course.uri'},
                                         $errtext);                                          $errtext);

Removed from v.1.132  
changed lines
  Added in v.1.133


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>