Merge "LockFile.commit: retry renaming"
This commit is contained in:
commit
6462be8350
|
@ -397,7 +397,7 @@ public boolean commit() {
|
||||||
if (lck.renameTo(ref))
|
if (lck.renameTo(ref))
|
||||||
return true;
|
return true;
|
||||||
if (!ref.exists() || deleteRef())
|
if (!ref.exists() || deleteRef())
|
||||||
if (lck.renameTo(ref))
|
if (renameLock())
|
||||||
return true;
|
return true;
|
||||||
unlock();
|
unlock();
|
||||||
return false;
|
return false;
|
||||||
|
@ -422,6 +422,25 @@ private boolean deleteRef() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean renameLock() {
|
||||||
|
if (!fs.retryFailedLockFileCommit())
|
||||||
|
return lck.renameTo(ref);
|
||||||
|
|
||||||
|
// File renaming fails on windows if another thread is
|
||||||
|
// concurrently reading the same file. So try a few times.
|
||||||
|
//
|
||||||
|
for (int attempts = 0; attempts < 10; attempts++) {
|
||||||
|
if (lck.renameTo(ref))
|
||||||
|
return true;
|
||||||
|
try {
|
||||||
|
Thread.sleep(100);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void saveStatInformation() {
|
private void saveStatInformation() {
|
||||||
if (needStatInformation)
|
if (needStatInformation)
|
||||||
commitLastModified = lck.lastModified();
|
commitLastModified = lck.lastModified();
|
||||||
|
|
Loading…
Reference in New Issue