simplified and bugfixed occasional lock contention.
authorjprocter <jprocter@compbio.dundee.ac.uk>
Thu, 8 Mar 2007 14:18:23 +0000 (14:18 +0000)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Thu, 8 Mar 2007 14:18:23 +0000 (14:18 +0000)
git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@355 be28352e-c001-0410-b1a7-c7978e42abec

src/uk/ac/vamsas/client/simpleclient/FileLock.java
src/uk/ac/vamsas/client/simpleclient/NativeLock.java

index c7d6150..c069d95 100644 (file)
@@ -48,9 +48,10 @@ public class FileLock extends Lock {
    */
   private void tidy() {
     if (_lock!=null) { 
-      if ( advisory!=null) 
+      if ( advisory!=null) {
         advisory.release(true);
-      advisory.target.deleteOnExit();
+        advisory.target.deleteOnExit();
+      }
       advisory=null;
       _lock=null;
     }
index 8a0124c..69b7155 100644 (file)
@@ -70,9 +70,11 @@ public class NativeLock extends Lock {
   }
 
   public void release(boolean closeChannel) {
+    if (lock==null)
+      return;
     try {
       // channel.close should be called before release() for rigourous locking.
-      if (rafile!=null && rafile.getFD().valid() && rafile.getChannel()!=null && lock.isValid()) {
+      if (lock.isValid() && rafile!=null && rafile.getFD().valid() && rafile.getChannel()!=null) {
         if (closeChannel && rafile.getChannel().isOpen()) {
             rafile.close();
             rafile=null;