[LON-CAPA-cvs] cvs: loncom / LONCAPA.pm

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 27 Jun 2006 14:49:29 -0000


albertel		Tue Jun 27 10:49:29 2006 EDT

  Modified files:              
    /loncom	LONCAPA.pm 
  Log:
  - currently the hash locking mechanism only support one has at a time, detects this and bomb on multiple calls
  
  
Index: loncom/LONCAPA.pm
diff -u loncom/LONCAPA.pm:1.8 loncom/LONCAPA.pm:1.9
--- loncom/LONCAPA.pm:1.8	Mon Jun 26 17:19:36 2006
+++ loncom/LONCAPA.pm	Tue Jun 27 10:49:29 2006
@@ -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 _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 @@
                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");
         }