mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
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
This commit is contained in:
parent
1981d5905d
commit
868db5b9b6
1 changed files with 10 additions and 5 deletions
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.dsf.gdb.internal.ui.actions;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||||
|
@ -177,6 +178,12 @@ public class DsfTerminateCommand implements ITerminateHandler {
|
||||||
* See bug 377447
|
* See bug 377447
|
||||||
*/
|
*/
|
||||||
private void waitForTermination(final IDebugCommandRequest request) {
|
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
|
// It is possible that the session already had time to terminate
|
||||||
if (!DsfSession.isSessionActive(fSession.getId())) {
|
if (!DsfSession.isSessionActive(fSession.getId())) {
|
||||||
request.done();
|
request.done();
|
||||||
|
@ -189,6 +196,8 @@ public class DsfTerminateCommand implements ITerminateHandler {
|
||||||
public void sessionEnded(DsfSession session) {
|
public void sessionEnded(DsfSession session) {
|
||||||
if (fSession.equals(session)) {
|
if (fSession.equals(session)) {
|
||||||
DsfSession.removeSessionEndedListener(this);
|
DsfSession.removeSessionEndedListener(this);
|
||||||
|
// Cancel the cleanup job since we won't need it
|
||||||
|
fFutureWrapper.fFuture.cancel(false);
|
||||||
GdbLaunch launch = getLaunch(request);
|
GdbLaunch launch = getLaunch(request);
|
||||||
if (launch != null) {
|
if (launch != null) {
|
||||||
terminateRemainingProcesses(launch, request);
|
terminateRemainingProcesses(launch, request);
|
||||||
|
@ -208,11 +217,7 @@ public class DsfTerminateCommand implements ITerminateHandler {
|
||||||
// session is also terminated before the timeout).
|
// session is also terminated before the timeout).
|
||||||
// We haven't found a problem with delaying the completion
|
// We haven't found a problem with delaying the completion
|
||||||
// of the request that way.
|
// of the request that way.
|
||||||
// Note that this timeout is not removed even if we don't
|
fFutureWrapper.fFuture = fExecutor.schedule(new Runnable() {
|
||||||
// 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() {
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// Check that the session is still active when the timeout hits.
|
// Check that the session is still active when the timeout hits.
|
||||||
|
|
Loading…
Add table
Reference in a new issue