Diff for /loncom/LONCAPA.pm between versions 1.8 and 1.10

version 1.8, 2006/06/26 21:19:36 version 1.10, 2006/06/27 15:21:28
Line 228  sub _do_hash_untie { Line 228  sub _do_hash_untie {
   
 {  {
     my $sym;      my $sym;
       my @pushed_syms;
       sub push_locking_hash_tie {
    if (!defined($sym)) {
       die("Invalid used of push_locking_hash_tie, should only be called after a lock has occurred and before and unlock.");
    }
    push(@pushed_syms,$sym);
    undef($sym);
       }
   
       sub pop_locking_hash_tie {
    if (defined($sym)) {
       die("Invalid nested used of pop_locking_hash_tie, should only be called after a unlock has occurred.");
    }
    $sym = pop(@pushed_syms);
       }
   
     sub _locking_hash_tie {      sub _locking_hash_tie {
  my ($file_prefix,$namespace,$how,$loghead,$what) = @_;   my ($file_prefix,$namespace,$how,$loghead,$what) = @_;
    if (defined($sym)) {
       die('Nested locking attempted withut proper use of push_locking_hahs_tie, this is unsupportted');
    }
   
         my $lock_type=LOCK_SH;          my $lock_type=LOCK_SH;
 # Are we reading or writing?  # Are we reading or writing?
         if ($how eq &GDBM_READER()) {          if ($how eq &GDBM_READER()) {
Line 248  sub _do_hash_untie { Line 267  sub _do_hash_untie {
                open($sym,">>$file_prefix.db.lock");                 open($sym,">>$file_prefix.db.lock");
            }             }
 # Do a shared lock  # Do a shared lock
            if (!&flock_sym(LOCK_SH)) { return undef; }              if (!&flock_sym(LOCK_SH)) { 
          return undef; 
      } 
 # If this is compressed, we will actually need an exclusive lock  # If this is compressed, we will actually need an exclusive lock
    if (-e "$file_prefix.db.gz") {     if (-e "$file_prefix.db.gz") {
        if (!&flock_sym(LOCK_EX)) { return undef; }         if (!&flock_sym(LOCK_EX)) {
      return undef;
          }
    }     }
         } elsif ($how eq &GDBM_WRCREAT()) {          } elsif ($how eq &GDBM_WRCREAT()) {
 # We are writing  # We are writing
            open($sym,">>$file_prefix.db.lock");             open($sym,">>$file_prefix.db.lock");
 # Writing needs exclusive lock  # Writing needs exclusive lock
            if (!&flock_sym(LOCK_EX)) { return undef; }             if (!&flock_sym(LOCK_EX)) {
          return undef;
      }
         } else {          } else {
            die("Unknown method $how for $file_prefix");             die("Unknown method $how for $file_prefix");
         }          }

Removed from v.1.8  
changed lines
  Added in v.1.10


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