summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2010-12-06 18:55:18 -0500
committerCode Review <codereview-daemon@eclipse.org>2010-12-06 18:55:18 -0500
commit6462be83505f0980df54ea3e41dce69b13fb44b7 (patch)
tree3e8f977e6ca2c9f1abb49279a3428aec6d7c0414 /org.eclipse.jgit
parent6d08252b11e7dd30939ce61cd1c5b1bdbbd1e89a (diff)
parentcbf5ff6ac7762e2b7170edae9d1563ae3869544a (diff)
downloadjgit-6462be83505f0980df54ea3e41dce69b13fb44b7.tar.gz
jgit-6462be83505f0980df54ea3e41dce69b13fb44b7.zip
Merge "LockFile.commit: retry renaming"
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/file/LockFile.java21
1 files changed, 20 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/LockFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/LockFile.java
index 6199f4c450..c1fb704a51 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/LockFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/LockFile.java
@@ -397,7 +397,7 @@ public class LockFile {
if (lck.renameTo(ref))
return true;
if (!ref.exists() || deleteRef())
- if (lck.renameTo(ref))
+ if (renameLock())
return true;
unlock();
return false;
@@ -422,6 +422,25 @@ public class LockFile {
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() {
if (needStatInformation)
commitLastModified = lck.lastModified();