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

NEW - bug 206883: [terminal][leak] VT100TerminalControl keeps a Job running even after disconnect

https://bugs.eclipse.org/bugs/show_bug.cgi?id=206883
applied patch by Martin Oberhuber
This commit is contained in:
Michael Scharf 2007-10-22 05:08:24 +00:00
parent 3e40a63159
commit ea883b0865

View file

@ -14,6 +14,7 @@
* Michael Scharf (Wind River) - split into core, view and connector plugins
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
* Martin Oberhuber (Wind River) - [206892] State handling: Only allow connect when CLOSED
* Martin Oberhuber (Wind River) - [206883] Serial Terminal leaks Jobs
*******************************************************************************/
package org.eclipse.tm.internal.terminal.emulator;
@ -107,6 +108,9 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
private final ITerminalTextData fTerminalModel;
/**
* Is protected by synchronize on this
*/
volatile private Job fJob;
public VT100TerminalControl(ITerminalListener target, Composite wndParent, ITerminalConnectorInfo[] connectors) {
@ -288,7 +292,22 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
if(getTerminalConnector()!=null) {
getTerminalConnector().disconnect();
}
}
//Ensure that a new Job can be started; then clean up old Job.
//TODO not sure whether the fInputStream needs to be cleaned too,
//or whether the Job could actually cancel in case the fInputStream is closed.
Job job;
synchronized(this) {
job = fJob;
fJob = null;
}
if (job!=null) {
job.cancel();
//There's not really a need to interrupt, since the job will
//check its cancel status after 500 msec latest anyways...
//Thread t = job.getThread();
//if(t!=null) t.interrupt();
}
}
// TODO
private void waitForConnect() {
@ -313,7 +332,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
}
private void startReaderJob() {
private synchronized void startReaderJob() {
if(fJob==null) {
fJob=new Job("Terminal data reader") { //$NON-NLS-1$
protected IStatus run(IProgressMonitor monitor) {