X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Forg%2Fvamsas%2Fclient%2Fsimpleclient%2FSessionFile.java;h=bd2dc449c00a7753ba6b5e168fc7936e21fb54f2;hb=d4199f5cfea3a90baeb956c4beaa2f3e8c0597c6;hp=9da73c0b8f3bb8d552fe7fc84343427a5edfb610;hpb=f40af7ef35b8599c22df9a4495dcc49531324f95;p=vamsas.git diff --git a/src/org/vamsas/client/simpleclient/SessionFile.java b/src/org/vamsas/client/simpleclient/SessionFile.java index 9da73c0..bd2dc44 100644 --- a/src/org/vamsas/client/simpleclient/SessionFile.java +++ b/src/org/vamsas/client/simpleclient/SessionFile.java @@ -33,7 +33,7 @@ public class SessionFile { fileLock=null; } if (extantlock!=null) - fileLock=extantlock; + fileLock=extantlock; // THIS IS BROKEN - lockFile then nulls the lock. return lockFile(); } @@ -49,7 +49,6 @@ public class SessionFile { else // lock failed for some reason. fileLock.release(); - fileLock = null; if (sessionFile != null) { if (!sessionFile.exists()) { // create new file @@ -68,9 +67,11 @@ public class SessionFile { long tries=500; do { tries--; - if (fileLock!=null && !fileLock.isLocked()) + if (fileLock!=null && !fileLock.isLocked()) { fileLock.release(); - fileLock = new Lock(sessionFile); // TODO: wait around if we can't get the lock. + try { Thread.sleep(5); } catch (Exception e) {}; + } + fileLock = LockFactory.getLock(sessionFile); // TODO: wait around if we can't get the lock. } while (tries>0 && !fileLock.isLocked()); if (!fileLock.isLocked()) log.error("Failed to get lock for "+sessionFile); @@ -134,8 +135,10 @@ public class SessionFile { if (newData.sessionFile==null) throw new IOException("Null SessionFile in newData."); - lockFile(extantLock); - newData.lockFile(); + if (!lockFile(extantLock)) + log.error("Failed to get write lock for "+sessionFile); + if (!newData.lockFile()) + log.warn("Failed to get lock for updateFrom "+newData.sessionFile); fileLock.rafile.getChannel().transferFrom(newData.fileLock.rafile.getChannel(), 0, newData.fileLock.rafile.length()); }