X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Forg%2Fvamsas%2Fclient%2Fsimpleclient%2FClientsFile.java;h=cab03cddad35eb0c6b1db6bb564425e1f0197ebc;hb=d4199f5cfea3a90baeb956c4beaa2f3e8c0597c6;hp=598bfdd2996724a557ad218175ce13c4f0677d23;hpb=099b683e189083f696a3b58888380c5fcff0ab38;p=vamsas.git diff --git a/src/org/vamsas/client/simpleclient/ClientsFile.java b/src/org/vamsas/client/simpleclient/ClientsFile.java index 598bfdd..cab03cd 100644 --- a/src/org/vamsas/client/simpleclient/ClientsFile.java +++ b/src/org/vamsas/client/simpleclient/ClientsFile.java @@ -43,8 +43,8 @@ public class ClientsFile extends ListFile { try { ClientHandle[] clients=null; if (this.fileLock.rafile.length()>0) { - ObjectInputStream is = new ObjectInputStream(new BufferedInputStream( - new java.io.FileInputStream(sessionFile))); + + ObjectInputStream is = new ObjectInputStream(fileLock.getBufferedInputStream(true)); Object o; o=is.readObject(); if (o!=null) { @@ -179,6 +179,9 @@ public class ClientsFile extends ListFile { */ protected int addClient(ClientHandle me, boolean disambiguate) { int newclient = 0; + int tries=5; + while (tries-->0 && !lockFile()) + try { Thread.sleep(1); } catch (Exception e){}; if (lockFile()) { ClientHandle[] clients = retrieveClientHandles(); if (me.getClientUrn()==null) { @@ -231,11 +234,14 @@ public class ClientsFile extends ListFile { File templist = backupSessionFile(); if (templist != null) { try { - fileLock.rafile.setLength(0); - ObjectOutputStream os = new ObjectOutputStream( - new BufferedOutputStream(new FileOutputStream(this.sessionFile))); + // fileLock.rafile.setLength(0); + ObjectOutputStream os = + new ObjectOutputStream(fileLock.getBufferedOutputStream(true)); + +// new BufferedOutputStream(new FileOutputStream(this.sessionFile))); + // new BufferedOutputStream(new FileOutputStream(this.fileLock.rafile.getFD()))); os.writeObject(clients); - os.close(); + os.close(); // close destroys lock! // All done - remove the backup. templist.delete(); templist = null;