From: jprocter Date: Thu, 8 Mar 2007 14:18:23 +0000 (+0000) Subject: simplified and bugfixed occasional lock contention. X-Git-Tag: Release_0.2~165 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=9d9b664b45909d1f3a718b0edb9119d0afa88baa;p=vamsas.git simplified and bugfixed occasional lock contention. git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@355 be28352e-c001-0410-b1a7-c7978e42abec --- diff --git a/src/uk/ac/vamsas/client/simpleclient/FileLock.java b/src/uk/ac/vamsas/client/simpleclient/FileLock.java index c7d6150..c069d95 100644 --- a/src/uk/ac/vamsas/client/simpleclient/FileLock.java +++ b/src/uk/ac/vamsas/client/simpleclient/FileLock.java @@ -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; } diff --git a/src/uk/ac/vamsas/client/simpleclient/NativeLock.java b/src/uk/ac/vamsas/client/simpleclient/NativeLock.java index 8a0124c..69b7155 100644 --- a/src/uk/ac/vamsas/client/simpleclient/NativeLock.java +++ b/src/uk/ac/vamsas/client/simpleclient/NativeLock.java @@ -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;