1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-31 21:05:37 +02:00

when terminate() is call disable the Command Queue

This commit is contained in:
Alain Magloire 2003-04-25 20:49:10 +00:00
parent 8f19b5929d
commit 8a98a043aa

View file

@ -275,9 +275,6 @@ public class MISession extends Observable {
*/ */
public synchronized void postCommand(Command cmd, long timeout) throws MIException { public synchronized void postCommand(Command cmd, long timeout) throws MIException {
// TRACING: print the command;
MIPlugin.getDefault().debugLog(cmd.toString());
// Test if we are in a sane state. // Test if we are in a sane state.
if (!txThread.isAlive() || !rxThread.isAlive()) { if (!txThread.isAlive() || !rxThread.isAlive()) {
throw new MIException("{R,T}xThread terminated"); throw new MIException("{R,T}xThread terminated");
@ -288,9 +285,17 @@ public class MISession extends Observable {
// REMINDER: if we support -exec-interrupt // REMINDER: if we support -exec-interrupt
// Let it throught: // Let it throught:
// if (cmd instanceof MIExecInterrupt) { } // if (cmd instanceof MIExecInterrupt) { }
// else
throw new MIException("Target is not suspended"); throw new MIException("Target is not suspended");
} }
if (isTerminated()) {
throw new MIException("Session terminated");
}
// TRACING: print the command;
MIPlugin.getDefault().debugLog(cmd.toString());
txQueue.addCommand(cmd); txQueue.addCommand(cmd);
// Wait for the response or timedout // Wait for the response or timedout
@ -364,11 +369,20 @@ public class MISession extends Observable {
OutputStream outGDB = outChannel; OutputStream outGDB = outChannel;
outChannel = null; outChannel = null;
// Although we will close the pipe(). It is cleaner
// to give a chance to gdb to cleanup.
// send the exit(-gdb-exit). // send the exit(-gdb-exit).
try { MIGDBExit exit = factory.createMIGDBExit();
MIGDBExit exit = factory.createMIGDBExit(); txQueue.addCommand(exit);
postCommand(exit);
} catch (MIException e) { // Wait for the response
synchronized (exit) {
// RxThread will set the MIOutput on the cmd
// when the response arrive.
try {
exit.wait(2000);
} catch (InterruptedException e) {
}
} }
// Make sure gdb is killed. // Make sure gdb is killed.
@ -446,14 +460,8 @@ public class MISession extends Observable {
} catch (InterruptedException e) { } catch (InterruptedException e) {
} }
// Flush the queue. // Tell the observers that the session is terminated
queue.clearItems();
// Tell the observers that the session
// is finish, but we can not use the Event Thread.
// The Event Thread was kill above.
notifyObservers(new MIGDBExitEvent(0)); notifyObservers(new MIGDBExitEvent(0));
} }
/** /**