Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPawel Piech2010-11-11 13:05:03 -0500
committerPawel Piech2010-11-11 13:05:03 -0500
commit8378c53a181ec16d9978a5c7974d16872535aa22 (patch)
treecfe520b6418020901e22028ca4563a8bb6dc6b55 /dsf/org.eclipse.cdt.dsf
parentb0f3b7b7689e2cef4c2b8e85b93e554478708e49 (diff)
downloadorg.eclipse.cdt-8378c53a181ec16d9978a5c7974d16872535aa22.tar.gz
org.eclipse.cdt-8378c53a181ec16d9978a5c7974d16872535aa22.tar.xz
org.eclipse.cdt-8378c53a181ec16d9978a5c7974d16872535aa22.zip
Bug 329488 - DSF ACPM deadlocks
Diffstat (limited to 'dsf/org.eclipse.cdt.dsf')
-rw-r--r--dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/AbstractCache.java66
-rw-r--r--dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/RequestMonitor.java11
2 files changed, 53 insertions, 24 deletions
diff --git a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/AbstractCache.java b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/AbstractCache.java
index e4ad222a07..1f22902065 100644
--- a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/AbstractCache.java
+++ b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/AbstractCache.java
@@ -195,45 +195,67 @@ public abstract class AbstractCache<V> implements ICache<V> {
}
+ /**
+ * Returns true if there are no clients waiting for this cache or if the
+ * clients that are waiting, have already canceled their requests.
+ * <p>
+ * Note: Calling this method may cause the client request monitors that were
+ * canceled to be completed with a cancel status. If all the client request
+ * monitors were canceled, this method will also cause the {@link #canceled()}
+ * method to be called. Both of these side effects will only happen
+ * asynchronously after <code>isCanceled()</code> returns.
+ * </p>
+ *
+ * @return <code>true</code> if all clients waiting on this cache have been
+ * canceled, or if there are no clients waiting at all.
+ */
@ThreadSafe
protected boolean isCanceled() {
boolean canceled;
List<RequestMonitor> canceledRms = null;
synchronized (this) {
- if (fWaitingList instanceof RequestMonitor && ((RequestMonitor)fWaitingList).isCanceled()) {
- canceledRms = new ArrayList<RequestMonitor>(1);
- canceledRms.add((RequestMonitor)fWaitingList);
- fWaitingList = null;
+ if (fWaitingList instanceof RequestMonitor) {
+ if ( ((RequestMonitor)fWaitingList).isCanceled() ) {
+ canceledRms = new ArrayList<RequestMonitor>(1);
+ canceledRms.add((RequestMonitor)fWaitingList);
+ canceled = true;
+ } else {
+ canceled = false;
+ }
} else if(fWaitingList instanceof RequestMonitor[]) {
- boolean waiting = false;
+ canceled = true;
RequestMonitor[] waitingList = (RequestMonitor[])fWaitingList;
for (int i = 0; i < waitingList.length; i++) {
- if (waitingList[i] != null && waitingList[i].isCanceled()) {
- if (canceledRms == null) {
- canceledRms = new ArrayList<RequestMonitor>(1);
+ if (waitingList[i] != null) {
+ if (waitingList[i].isCanceled()) {
+ if (canceledRms == null) {
+ canceledRms = new ArrayList<RequestMonitor>(1);
+ }
+ canceledRms.add( waitingList[i] );
+ } else {
+ canceled = false;
}
- canceledRms.add( waitingList[i] );
- waitingList[i] = null;
}
- waiting = waiting || waitingList[i] != null;
- }
- if (!waiting) {
- fWaitingList = null;
}
- }
- canceled = fWaitingList == null;
+ } else {
+ assert fWaitingList == null;
+ canceled = true;
+ }
}
if (canceledRms != null) {
- for (RequestMonitor canceledRm : canceledRms) {
- canceledRm.setStatus(Status.CANCEL_STATUS);
- canceledRm.removeCancelListener(fRequestCanceledListener);
- canceledRm.done();
- }
+ final List<RequestMonitor> _canceledRms = canceledRms;
+ fExecutor.getDsfExecutor().execute(new DsfRunnable() {
+ public void run() {
+ for (RequestMonitor canceledRm : _canceledRms) {
+ handleCanceledRm(canceledRm);
+ }
+ }
+ });
}
return canceled;
}
-
+
/**
* Resets the cache, setting the data to null and the status to
* INVALID_STATUS. When in the invalid state, neither the data nor the
diff --git a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/RequestMonitor.java b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/RequestMonitor.java
index 243713a074..09f876934b 100644
--- a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/RequestMonitor.java
+++ b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/RequestMonitor.java
@@ -233,8 +233,15 @@ public class RequestMonitor extends DsfExecutable {
* A request monitor is considered canceled if either it or its parent was canceled.
* </p>
*/
- public synchronized boolean isCanceled() {
- return fCanceled || (fParentRequestMonitor != null && fParentRequestMonitor.isCanceled());
+ public boolean isCanceled() {
+ boolean canceled = false;
+
+ // Avoid holding onto this lock while calling parent RM, which may
+ // acquire other locks (bug 329488).
+ synchronized(this) {
+ canceled = fCanceled;
+ }
+ return canceled || (fParentRequestMonitor != null && fParentRequestMonitor.isCanceled());
}
/**

Back to the top