mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-13 03:55:22 +02:00
RESOLVED - bug 240420: [terminal][ssh]Channel is not closed when the connection is closed with the close button
https://bugs.eclipse.org/bugs/show_bug.cgi?id=240420 Handle disconnect before fSession has been assigned
This commit is contained in:
parent
5be99fb66a
commit
09fc8554a1
1 changed files with 6 additions and 2 deletions
|
@ -48,6 +48,7 @@ class SshConnection extends Thread {
|
|||
private final ITerminalControl fControl;
|
||||
private final SshConnector fConn;
|
||||
private Session fSession;
|
||||
private boolean fDisconnectHasBeenCalled;
|
||||
protected SshConnection(SshConnector conn,ITerminalControl control) {
|
||||
super("SshConnection-"+fgNo++); //$NON-NLS-1$
|
||||
fControl = control;
|
||||
|
@ -120,7 +121,9 @@ class SshConnection extends Thread {
|
|||
session.setServerAliveInterval(nKeepalive); //default is 5 minutes
|
||||
}
|
||||
session.connect(nTimeout); // making connection with timeout.
|
||||
|
||||
// if we got disconnected, do not continue
|
||||
if(!isSessionConnected())
|
||||
return;
|
||||
ChannelShell channel=(ChannelShell) session.openChannel("shell"); //$NON-NLS-1$
|
||||
channel.setPtyType("ansi"); //$NON-NLS-1$
|
||||
channel.connect();
|
||||
|
@ -152,7 +155,7 @@ class SshConnection extends Thread {
|
|||
}
|
||||
|
||||
private synchronized boolean isSessionConnected() {
|
||||
return fSession != null && fSession.isConnected();
|
||||
return fDisconnectHasBeenCalled || (fSession != null && fSession.isConnected());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -161,6 +164,7 @@ class SshConnection extends Thread {
|
|||
void disconnect() {
|
||||
interrupt();
|
||||
synchronized (this) {
|
||||
fDisconnectHasBeenCalled=true;
|
||||
if(fSession!=null) {
|
||||
try {
|
||||
fSession.disconnect();
|
||||
|
|
Loading…
Add table
Reference in a new issue