mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
bug 371797: prevent possible deadlock for specs detectors
This commit is contained in:
parent
34b4b842ce
commit
fce6b5a258
1 changed files with 15 additions and 14 deletions
|
@ -107,6 +107,7 @@ public class LanguageSettingsProvidersSerializer {
|
||||||
|
|
||||||
private static ListenerList fLanguageSettingsChangeListeners = new ListenerList(ListenerList.IDENTITY);
|
private static ListenerList fLanguageSettingsChangeListeners = new ListenerList(ListenerList.IDENTITY);
|
||||||
private static ILock serializingLock = Job.getJobManager().newLock();
|
private static ILock serializingLock = Job.getJobManager().newLock();
|
||||||
|
private static ILock serializingLockWsp = Job.getJobManager().newLock();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dummy class to represent ill-defined provider.
|
* Dummy class to represent ill-defined provider.
|
||||||
|
@ -470,21 +471,21 @@ public class LanguageSettingsProvidersSerializer {
|
||||||
IProject[] projects = root.getProjects();
|
IProject[] projects = root.getProjects();
|
||||||
|
|
||||||
for (IProject project : projects) {
|
for (IProject project : projects) {
|
||||||
|
try {
|
||||||
if (project.isAccessible()) {
|
if (project.isAccessible()) {
|
||||||
ICProjectDescription prjDescription = CCorePlugin.getDefault().getProjectDescription(project, false);
|
ICProjectDescription prjDescription = CCorePlugin.getDefault().getProjectDescription(project, false);
|
||||||
if (prjDescription != null) {
|
if (prjDescription != null) {
|
||||||
try {
|
|
||||||
LanguageSettingsChangeEvent event = createEvent(prjDescription, providerIds);
|
LanguageSettingsChangeEvent event = createEvent(prjDescription, providerIds);
|
||||||
if (event != null) {
|
if (event != null) {
|
||||||
events.add(event);
|
events.add(event);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
// log and swallow any exception
|
// log and swallow any exception
|
||||||
CCorePlugin.log("Error creating event about changes in workspace language settings providers, " //$NON-NLS-1$
|
CCorePlugin.log("Error creating event about changes in workspace language settings providers, " //$NON-NLS-1$
|
||||||
+ "project=" + project.getName(), e); //$NON-NLS-1$
|
+ "project=" + project.getName(), e); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -513,12 +514,12 @@ public class LanguageSettingsProvidersSerializer {
|
||||||
if (serializableWorkspaceProviders.isEmpty()) {
|
if (serializableWorkspaceProviders.isEmpty()) {
|
||||||
java.io.File fileStoreWsp = new java.io.File(uriStoreWsp);
|
java.io.File fileStoreWsp = new java.io.File(uriStoreWsp);
|
||||||
try {
|
try {
|
||||||
serializingLock.acquire();
|
serializingLockWsp.acquire();
|
||||||
fileStoreWsp.delete();
|
fileStoreWsp.delete();
|
||||||
// manufacture events while inside the lock
|
// manufacture events while inside the lock
|
||||||
events = createLanguageSettingsChangeEvents(serializableWorkspaceProviders);
|
events = createLanguageSettingsChangeEvents(serializableWorkspaceProviders);
|
||||||
} finally {
|
} finally {
|
||||||
serializingLock.release();
|
serializingLockWsp.release();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Document doc = XmlUtil.newDocument();
|
Document doc = XmlUtil.newDocument();
|
||||||
|
@ -531,12 +532,12 @@ public class LanguageSettingsProvidersSerializer {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
serializingLock.acquire();
|
serializingLockWsp.acquire();
|
||||||
XmlUtil.serializeXml(doc, uriStoreWsp);
|
XmlUtil.serializeXml(doc, uriStoreWsp);
|
||||||
// manufacture events while inside the lock
|
// manufacture events while inside the lock
|
||||||
events = createLanguageSettingsChangeEvents(serializableWorkspaceProviders);
|
events = createLanguageSettingsChangeEvents(serializableWorkspaceProviders);
|
||||||
} finally {
|
} finally {
|
||||||
serializingLock.release();
|
serializingLockWsp.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// notify the listeners outside the lock
|
// notify the listeners outside the lock
|
||||||
|
@ -601,12 +602,12 @@ public class LanguageSettingsProvidersSerializer {
|
||||||
|
|
||||||
Document doc = null;
|
Document doc = null;
|
||||||
try {
|
try {
|
||||||
serializingLock.acquire();
|
serializingLockWsp.acquire();
|
||||||
doc = XmlUtil.loadXml(uriStoreWsp);
|
doc = XmlUtil.loadXml(uriStoreWsp);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CCorePlugin.log("Can't load preferences from file " + uriStoreWsp, e); //$NON-NLS-1$
|
CCorePlugin.log("Can't load preferences from file " + uriStoreWsp, e); //$NON-NLS-1$
|
||||||
} finally {
|
} finally {
|
||||||
serializingLock.release();
|
serializingLockWsp.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doc != null) {
|
if (doc != null) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue