diff options
author | John Eblen | 2011-09-13 22:05:17 +0000 |
---|---|---|
committer | John Eblen | 2011-09-13 22:05:17 +0000 |
commit | 412cb3b3613d8c3ea5ae112c1d43547c3a653204 (patch) | |
tree | b90e543ab5d62c6fa210eb067e58064e93809884 /rdt/org.eclipse.ptp.rdt.sync.git.core | |
parent | c036f28b6c6b44c1818f445236ff18d30cf5a9b3 (diff) | |
download | org.eclipse.ptp-412cb3b3613d8c3ea5ae112c1d43547c3a653204.tar.gz org.eclipse.ptp-412cb3b3613d8c3ea5ae112c1d43547c3a653204.tar.xz org.eclipse.ptp-412cb3b3613d8c3ea5ae112c1d43547c3a653204.zip |
Bug 357561: Fix the combining of synchronization calls
Diffstat (limited to 'rdt/org.eclipse.ptp.rdt.sync.git.core')
-rw-r--r-- | rdt/org.eclipse.ptp.rdt.sync.git.core/src/org/eclipse/ptp/rdt/sync/git/core/GitServiceProvider.java | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/rdt/org.eclipse.ptp.rdt.sync.git.core/src/org/eclipse/ptp/rdt/sync/git/core/GitServiceProvider.java b/rdt/org.eclipse.ptp.rdt.sync.git.core/src/org/eclipse/ptp/rdt/sync/git/core/GitServiceProvider.java index 59d827341..e38b71c5f 100644 --- a/rdt/org.eclipse.ptp.rdt.sync.git.core/src/org/eclipse/ptp/rdt/sync/git/core/GitServiceProvider.java +++ b/rdt/org.eclipse.ptp.rdt.sync.git.core/src/org/eclipse/ptp/rdt/sync/git/core/GitServiceProvider.java @@ -54,7 +54,8 @@ public class GitServiceProvider extends ServiceProvider implements ISyncServiceP private GitRemoteSyncConnection fSyncConnection = null; private boolean hasBeenSynced = false; - private final ReentrantLock syncLock = new ReentrantLock(); + private static final ReentrantLock syncLock = new ReentrantLock(); + private Integer fWaitingThreadsCount = 0; private Integer syncTaskId = -1; // ID for most recent synchronization task, functions as a time-stamp private int finishedSyncTaskId = -1; // all synchronizations up to this ID (including it) have finished @@ -202,8 +203,12 @@ public class GitServiceProvider extends ServiceProvider implements ISyncServiceP } if (resource.getType() == IResource.FOLDER) { IFile emptyFile = project.getFile(resource.getProjectRelativePath().addTrailingSeparator() + ".gitignore"); //$NON-NLS-1$ - if (!(emptyFile.exists())) { - emptyFile.create(new ByteArrayInputStream("".getBytes()), false, null); //$NON-NLS-1$ + try { + if (!(emptyFile.exists())) { + emptyFile.create(new ByteArrayInputStream("".getBytes()), false, null); //$NON-NLS-1$ + } + } catch (CoreException e){ + // Nothing to do. Can happen if another thread creates the file between the check and creation. } } return true; @@ -233,8 +238,12 @@ public class GitServiceProvider extends ServiceProvider implements ISyncServiceP && (delta.getKind() == IResourceDelta.ADDED || delta.getKind() == IResourceDelta.CHANGED)) { IFile emptyFile = getProject().getFile( delta.getResource().getProjectRelativePath().addTrailingSeparator() + ".gitignore"); //$NON-NLS-1$ - if (!(emptyFile.exists())) { - emptyFile.create(new ByteArrayInputStream("".getBytes()), false, null); //$NON-NLS-1$ + try { + if (!(emptyFile.exists())) { + emptyFile.create(new ByteArrayInputStream("".getBytes()), false, null); //$NON-NLS-1$ + } + } catch (CoreException e) { + // Nothing to do. Can happen if another thread creates the file between the check and creation. } } @@ -282,8 +291,13 @@ public class GitServiceProvider extends ServiceProvider implements ISyncServiceP // suggestion for Deltas: add delta to list of deltas } - if (syncLock.hasQueuedThreads() && syncFlags == SyncFlag.NO_FORCE) - return; // the queued Thread will do the work for us. And we don't have to wait because of NO_FORCE + synchronized (fWaitingThreadsCount) { + if (fWaitingThreadsCount > 0 && syncFlags == SyncFlag.NO_FORCE) { + return; // the queued thread will do the work for us. And we don't have to wait because of NO_FORCE + } else { + fWaitingThreadsCount++; + } + } // lock syncLock. interruptible by progress monitor try { @@ -294,6 +308,10 @@ public class GitServiceProvider extends ServiceProvider implements ISyncServiceP } } catch (InterruptedException e1) { throw new CoreException(new Status(IStatus.CANCEL, Activator.PLUGIN_ID, Messages.GitServiceProvider_2)); + } finally { + synchronized (fWaitingThreadsCount) { + fWaitingThreadsCount--; + } } try { |