--- loncom/LONCAPA.pm 2006/06/26 21:19:36 1.8 +++ loncom/LONCAPA.pm 2006/06/27 14:49:29 1.9 @@ -1,7 +1,7 @@ # The LearningOnline Network # Base routines # -# $Id: LONCAPA.pm,v 1.8 2006/06/26 21:19:36 foxr Exp $ +# $Id: LONCAPA.pm,v 1.9 2006/06/27 14:49:29 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -231,6 +231,10 @@ sub _do_hash_untie { sub _locking_hash_tie { my ($file_prefix,$namespace,$how,$loghead,$what) = @_; + if (defined($sym)) { + die('Nested locking attempted, this is unsupportted'); + } + my $lock_type=LOCK_SH; # Are we reading or writing? if ($how eq &GDBM_READER()) { @@ -248,16 +252,22 @@ sub _do_hash_untie { open($sym,">>$file_prefix.db.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 (-e "$file_prefix.db.gz") { - if (!&flock_sym(LOCK_EX)) { return undef; } + if (!&flock_sym(LOCK_EX)) { + return undef; + } } } elsif ($how eq &GDBM_WRCREAT()) { # We are writing open($sym,">>$file_prefix.db.lock"); # Writing needs exclusive lock - if (!&flock_sym(LOCK_EX)) { return undef; } + if (!&flock_sym(LOCK_EX)) { + return undef; + } } else { die("Unknown method $how for $file_prefix"); }