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) {
*/
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) {
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;