1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-01 06:05:24 +02:00

Bug 310007 core.resources can deadlock CDT project model.

This commit is contained in:
James Blackburn 2010-04-22 15:39:22 +00:00
parent cb4be96604
commit 63dc719a21
2 changed files with 16 additions and 9 deletions

View file

@ -443,7 +443,9 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
monitor = new NullProgressMonitor();
// Should the rule be scheduled, or run immediately
boolean scheduleRule = ResourcesPlugin.getWorkspace().isTreeLocked();
// Bug 310007 - Always unsafe to modify resources while data structure lock is held
boolean scheduleRule = true;
// boolean scheduleRule = ResourcesPlugin.getWorkspace().isTreeLocked();
// Check whether current job contains rule 'rule'
// If not, we must schedule another job to execute the runnable

View file

@ -48,9 +48,9 @@ import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionStorageManager;
import org.eclipse.cdt.internal.core.settings.model.ExceptionFactory;
import org.eclipse.cdt.internal.core.settings.model.ICProjectDescriptionStorageType;
import org.eclipse.cdt.internal.core.settings.model.ICProjectDescriptionStorageType.CProjectDescriptionStorageTypeProxy;
import org.eclipse.cdt.internal.core.settings.model.SettingsContext;
import org.eclipse.cdt.internal.core.settings.model.SettingsModelMessages;
import org.eclipse.cdt.internal.core.settings.model.ICProjectDescriptionStorageType.CProjectDescriptionStorageTypeProxy;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileInfo;
import org.eclipse.core.filesystem.IFileStore;
@ -61,6 +61,7 @@ import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@ -120,6 +121,8 @@ public class XmlProjectDescriptionStorage extends AbstractCProjectDescriptionSto
super(type, project, version);
}
private int desSerialTotalCount;
private volatile int desSerialCurrent;
/**
* The workspace runnable that actually goes about serializing the project description
@ -127,20 +130,22 @@ public class XmlProjectDescriptionStorage extends AbstractCProjectDescriptionSto
private class DesSerializationRunnable implements IWorkspaceRunnable {
private final ICProjectDescription fDes;
private final ICStorageElement fElement;
private final int serializingNumber;
public DesSerializationRunnable(ICProjectDescription des, ICStorageElement el) {
fDes = des;
fElement = el;
serializingNumber = desSerialTotalCount++;
}
public void run(IProgressMonitor monitor) throws CoreException {
try {
serializingLock.acquire();
projectModificaitonStamp = serialize(fDes.getProject(), ICProjectDescriptionStorageType.STORAGE_FILE_NAME, fElement);
((ContributedEnvironment) CCorePlugin.getDefault().getBuildEnvironmentManager().getContributedEnvironment()).serialize(fDes);
} finally {
serializingLock.release();
}
// Asserting that the platform job API stands by its committment to run jobs
// with conflicting scheduling rules in strict order -- so the project configuration
// at the end of a batch of changes is consistent.
Assert.isTrue(serializingNumber == desSerialCurrent);
desSerialCurrent++;
projectModificaitonStamp = serialize(fDes.getProject(), ICProjectDescriptionStorageType.STORAGE_FILE_NAME, fElement);
((ContributedEnvironment) CCorePlugin.getDefault().getBuildEnvironmentManager().getContributedEnvironment()).serialize(fDes);
}
}