diff options
author | Marc Khouzam | 2017-03-08 19:24:45 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2017-03-27 19:08:46 +0000 |
commit | 868db5b9b60effc33609a9d440f614f5221ab6da (patch) | |
tree | 9cac98e25d332f03e61e3f0fd3dc7c83e9ba607e | |
parent | 1981d5905d23e714eaf4be8d9bf5b5fd050b1c64 (diff) | |
download | org.eclipse.cdt-868db5b9b60effc33609a9d440f614f5221ab6da.tar.gz org.eclipse.cdt-868db5b9b60effc33609a9d440f614f5221ab6da.tar.xz org.eclipse.cdt-868db5b9b60effc33609a9d440f614f5221ab6da.zip |
Bug 512180: Ensure previous launch is fully terminated
DsfTerminateCommand leaves a timeout job on the executor queue, remove
it proactively so the executor doesn't sit around just waiting
for it to terminate.
Change-Id: If26411a5b6e0d35a1c45582e91ba62d24cef6bbb
-rw-r--r-- | dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DsfTerminateCommand.java | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DsfTerminateCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DsfTerminateCommand.java index 6c3c2208c50..92d5d6c9bb4 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DsfTerminateCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DsfTerminateCommand.java @@ -13,6 +13,7 @@ package org.eclipse.cdt.dsf.gdb.internal.ui.actions; import java.util.HashSet; import java.util.Set; +import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; @@ -177,6 +178,12 @@ public class DsfTerminateCommand implements ITerminateHandler { * See bug 377447 */ private void waitForTermination(final IDebugCommandRequest request) { + class ScheduledFutureWrapper { + ScheduledFuture<?> fFuture; + }; + + final ScheduledFutureWrapper fFutureWrapper = new ScheduledFutureWrapper(); + // It is possible that the session already had time to terminate if (!DsfSession.isSessionActive(fSession.getId())) { request.done(); @@ -189,6 +196,8 @@ public class DsfTerminateCommand implements ITerminateHandler { public void sessionEnded(DsfSession session) { if (fSession.equals(session)) { DsfSession.removeSessionEndedListener(this); + // Cancel the cleanup job since we won't need it + fFutureWrapper.fFuture.cancel(false); GdbLaunch launch = getLaunch(request); if (launch != null) { terminateRemainingProcesses(launch, request); @@ -208,11 +217,7 @@ public class DsfTerminateCommand implements ITerminateHandler { // session is also terminated before the timeout). // We haven't found a problem with delaying the completion // of the request that way. - // Note that this timeout is not removed even if we don't - // need it anymore, once the session has terminated; - // instead, we let it timeout and ignore it if the session - // is already terminated. - fExecutor.schedule(new Runnable() { + fFutureWrapper.fFuture = fExecutor.schedule(new Runnable() { @Override public void run() { // Check that the session is still active when the timeout hits. |