protected boolean lockFile(Lock extantlock) {
if (fileLock!=null && !fileLock.isLocked()) {
fileLock.release();// tidy up invalid lock
+ fileLock=null;
}
- fileLock=extantlock;
+ if (extantlock!=null)
+ fileLock=extantlock;
return lockFile();
}
}
// TODO: see if we need to loop-wait for locks or they just block until
// lock is made...
+ long tries=500;
do {
- if (fileLock!=null)
+ tries--;
+ if (fileLock!=null && !fileLock.isLocked())
fileLock.release();
fileLock = new Lock(sessionFile); // TODO: wait around if we can't get the lock.
- } while (!fileLock.isLocked());
+ } while (tries>0 && !fileLock.isLocked());
+ if (!fileLock.isLocked())
+ log.error("Failed to get lock for "+sessionFile);
// fileLock = new Lock(sessionFile);
return fileLock.isLocked();
} else