1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 09:16:02 +02:00

Bug 540085 - Deadlock in ToolChainManager init

- modify ContainerGCCToolChainProvider.init so that the
  CBuildConfigurationManager.recheckConfigs() call is done
  within a separate job so the init() call will return
  without causing deadlock
- do the same for ContainerTargetTypeProvider
- modify CBuildConfigurationManager initProviders() method to
  be synchronized

Change-Id: I4ca9371fb340887233872b6d315621a24450fb2b
This commit is contained in:
Jeff Johnston 2018-10-12 13:09:43 -04:00
parent efbda46cba
commit c9eee479b4
3 changed files with 39 additions and 14 deletions

View file

@ -101,7 +101,7 @@ public class CBuildConfigurationManager implements ICBuildConfigurationManager,
ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
}
private void initProviders() {
private synchronized void initProviders() {
if (providers == null) {
providers = new HashMap<>();

View file

@ -123,12 +123,25 @@ public class ContainerTargetTypeProvider
DockerConnectionManager.getInstance()
.addConnectionManagerListener(this);
// call the recheckConfigs method in case any disabled targets are now
// ok
ICBuildConfigurationManager mgr = CCorePlugin
.getService(ICBuildConfigurationManager.class);
ICBuildConfigurationManager2 manager = (ICBuildConfigurationManager2) mgr;
manager.recheckConfigs();
// re-check configs in case an enabled Connection has made old configs
// valid again do this in a separate job to prevent a possible
// deadlock trying to get the lock on the CBuildConfigurationManager
// "configs" map (Bug 540085)
Job checkConfigs = new Job("Check configs") { //$NON-NLS-1$
@Override
protected IStatus run(IProgressMonitor monitor) {
// call the recheckConfigs method in case any disabled targets
// are now
// ok
ICBuildConfigurationManager mgr = CCorePlugin
.getService(ICBuildConfigurationManager.class);
ICBuildConfigurationManager2 cbuildmanager = (ICBuildConfigurationManager2) mgr;
cbuildmanager.recheckConfigs();
return Status.OK_STATUS;
}
};
checkConfigs.setUser(true);
checkConfigs.schedule();
try {
launchbarManager.setActiveLaunchTarget(defaultTarget);

View file

@ -98,13 +98,25 @@ public class ContainerGCCToolChainProvider
DockerConnectionManager.getInstance()
.addConnectionManagerListener(this);
// call the recheckConfigs method in case any disabled targets are now
// ok
ICBuildConfigurationManager mgr = CCorePlugin
.getService(ICBuildConfigurationManager.class);
ICBuildConfigurationManager2 cbuildmanager = (ICBuildConfigurationManager2) mgr;
cbuildmanager.recheckConfigs();
// re-check configs in case an enabled Connection has made old configs
// valid again do this in a separate job to prevent a possible
// deadlock trying to get the lock on the CBuildConfigurationManager
// "configs" map (Bug 540085)
Job checkConfigs = new Job("Check configs") { //$NON-NLS-1$
@Override
protected IStatus run(IProgressMonitor monitor) {
// call the recheckConfigs method in case any disabled targets
// are now
// ok
ICBuildConfigurationManager mgr = CCorePlugin
.getService(ICBuildConfigurationManager.class);
ICBuildConfigurationManager2 cbuildmanager = (ICBuildConfigurationManager2) mgr;
cbuildmanager.recheckConfigs();
return Status.OK_STATUS;
}
};
checkConfigs.setUser(true);
checkConfigs.schedule();
}
@Override