mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-28 19:35:36 +02:00
Bug 310007 core.resources can deadlock CDT project model.
This commit is contained in:
parent
cb4be96604
commit
63dc719a21
2 changed files with 16 additions and 9 deletions
|
@ -443,7 +443,9 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
||||||
monitor = new NullProgressMonitor();
|
monitor = new NullProgressMonitor();
|
||||||
|
|
||||||
// Should the rule be scheduled, or run immediately
|
// 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'
|
// Check whether current job contains rule 'rule'
|
||||||
// If not, we must schedule another job to execute the runnable
|
// If not, we must schedule another job to execute the runnable
|
||||||
|
|
|
@ -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.CProjectDescriptionStorageManager;
|
||||||
import org.eclipse.cdt.internal.core.settings.model.ExceptionFactory;
|
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;
|
||||||
|
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.SettingsContext;
|
||||||
import org.eclipse.cdt.internal.core.settings.model.SettingsModelMessages;
|
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.EFS;
|
||||||
import org.eclipse.core.filesystem.IFileInfo;
|
import org.eclipse.core.filesystem.IFileInfo;
|
||||||
import org.eclipse.core.filesystem.IFileStore;
|
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.IResource;
|
||||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
import org.eclipse.core.runtime.Assert;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
@ -120,6 +121,8 @@ public class XmlProjectDescriptionStorage extends AbstractCProjectDescriptionSto
|
||||||
super(type, project, version);
|
super(type, project, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int desSerialTotalCount;
|
||||||
|
private volatile int desSerialCurrent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The workspace runnable that actually goes about serializing the project description
|
* 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 class DesSerializationRunnable implements IWorkspaceRunnable {
|
||||||
private final ICProjectDescription fDes;
|
private final ICProjectDescription fDes;
|
||||||
private final ICStorageElement fElement;
|
private final ICStorageElement fElement;
|
||||||
|
private final int serializingNumber;
|
||||||
|
|
||||||
public DesSerializationRunnable(ICProjectDescription des, ICStorageElement el) {
|
public DesSerializationRunnable(ICProjectDescription des, ICStorageElement el) {
|
||||||
fDes = des;
|
fDes = des;
|
||||||
fElement = el;
|
fElement = el;
|
||||||
|
serializingNumber = desSerialTotalCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(IProgressMonitor monitor) throws CoreException {
|
public void run(IProgressMonitor monitor) throws CoreException {
|
||||||
try {
|
// Asserting that the platform job API stands by its committment to run jobs
|
||||||
serializingLock.acquire();
|
// with conflicting scheduling rules in strict order -- so the project configuration
|
||||||
projectModificaitonStamp = serialize(fDes.getProject(), ICProjectDescriptionStorageType.STORAGE_FILE_NAME, fElement);
|
// at the end of a batch of changes is consistent.
|
||||||
((ContributedEnvironment) CCorePlugin.getDefault().getBuildEnvironmentManager().getContributedEnvironment()).serialize(fDes);
|
Assert.isTrue(serializingNumber == desSerialCurrent);
|
||||||
} finally {
|
desSerialCurrent++;
|
||||||
serializingLock.release();
|
projectModificaitonStamp = serialize(fDes.getProject(), ICProjectDescriptionStorageType.STORAGE_FILE_NAME, fElement);
|
||||||
}
|
((ContributedEnvironment) CCorePlugin.getDefault().getBuildEnvironmentManager().getContributedEnvironment()).serialize(fDes);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue