1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

fixed bug with failure case in initializing container and leaving lock in map

This commit is contained in:
David Inglis 2004-08-20 19:28:09 +00:00
parent 8abbfa146e
commit f693b0966d

View file

@ -480,7 +480,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
containerPut(affectedProject, containerPath, newContainer); containerPut(affectedProject, containerPath, newContainer);
continue; continue;
} }
IPathEntryContainer oldContainer = containerGet(affectedProject, containerPath); IPathEntryContainer oldContainer = containerGet(affectedProject, containerPath, true);
if (oldContainer != null && newContainer != null && oldContainer.equals(newContainer)) { if (oldContainer != null && newContainer != null && oldContainer.equals(newContainer)) {
modifiedProjects[i] = null; // filter out this project - modifiedProjects[i] = null; // filter out this project -
// container did not change // container did not change
@ -544,7 +544,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
public IPathEntryContainer getPathEntryContainer(final IPath containerPath, final ICProject project) throws CModelException { public IPathEntryContainer getPathEntryContainer(final IPath containerPath, final ICProject project) throws CModelException {
// Try the cache. // Try the cache.
IPathEntryContainer container = containerGet(project, containerPath); IPathEntryContainer container = containerGet(project, containerPath, true);
if (container instanceof PathEntryContainerLock) { if (container instanceof PathEntryContainerLock) {
boolean runInitializer = false; boolean runInitializer = false;
PathEntryContainerLock lock = (PathEntryContainerLock)container; PathEntryContainerLock lock = (PathEntryContainerLock)container;
@ -554,7 +554,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
lock.setContainerInitialize(runInitializer); lock.setContainerInitialize(runInitializer);
} else { } else {
// Wait for the inialization to finish. // Wait for the inialization to finish.
while(containerGet(project, containerPath) instanceof PathEntryContainerLock) { while(containerGet(project, containerPath, true) instanceof PathEntryContainerLock) {
try { try {
lock.wait(); lock.wait();
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -590,7 +590,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
} }
} }
// retrieve new value // retrieve new value
container = containerGet(project, containerPath); container = containerGet(project, containerPath, false);
} }
return container; return container;
} }
@ -637,7 +637,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
return null; return null;
} }
private synchronized IPathEntryContainer containerGet(ICProject cproject, IPath containerPath) { private synchronized IPathEntryContainer containerGet(ICProject cproject, IPath containerPath, boolean bCreateLock) {
Map projectContainers = (Map) Containers.get(cproject); Map projectContainers = (Map) Containers.get(cproject);
if (projectContainers == null) { if (projectContainers == null) {
projectContainers = new HashMap(); projectContainers = new HashMap();
@ -645,7 +645,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
} }
IPathEntryContainer container = (IPathEntryContainer) projectContainers.get(containerPath); IPathEntryContainer container = (IPathEntryContainer) projectContainers.get(containerPath);
// Initialize the first time with a lock // Initialize the first time with a lock
if (container == null) { if (bCreateLock && container == null ) {
container = new PathEntryContainerLock(); container = new PathEntryContainerLock();
projectContainers.put(containerPath, container); projectContainers.put(containerPath, container);
} }
@ -658,7 +658,12 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
projectContainers = new HashMap(); projectContainers = new HashMap();
Containers.put(cproject, projectContainers); Containers.put(cproject, projectContainers);
} }
IPathEntryContainer oldContainer = (IPathEntryContainer)projectContainers.put(containerPath, container); IPathEntryContainer oldContainer;
if (container == null) {
oldContainer = (IPathEntryContainer)projectContainers.remove(containerPath);
} else {
oldContainer = (IPathEntryContainer)projectContainers.put(containerPath, container);
}
if (oldContainer instanceof PathEntryContainerLock) { if (oldContainer instanceof PathEntryContainerLock) {
synchronized (oldContainer) { synchronized (oldContainer) {
oldContainer.notifyAll(); oldContainer.notifyAll();