Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 70316 Details for
Bug 187301
[telnet] Telnet does not allow multiple shells
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
new patch for 187301
patch187301.txt (text/plain), 11.01 KB, created by
Sheldon
on 2007-06-06 09:02:20 EDT
(
hide
)
Description:
new patch for 187301
Filename:
MIME Type:
Creator:
Sheldon
Created:
2007-06-06 09:02:20 EDT
Size:
11.01 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rse.connectorservice.telnet >Index: src/org/eclipse/rse/internal/connectorservice/telnet/TelnetConnectorService.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.connectorservice.telnet/src/org/eclipse/rse/internal/connectorservice/telnet/TelnetConnectorService.java,v >retrieving revision 1.11 >diff -u -r1.11 TelnetConnectorService.java >--- src/org/eclipse/rse/internal/connectorservice/telnet/TelnetConnectorService.java 16 May 2007 15:52:44 -0000 1.11 >+++ src/org/eclipse/rse/internal/connectorservice/telnet/TelnetConnectorService.java 6 Jun 2007 12:54:48 -0000 >@@ -23,6 +23,7 @@ > > import org.apache.commons.net.telnet.TelnetClient; > import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.NullProgressMonitor; > import org.eclipse.core.runtime.OperationCanceledException; > import org.eclipse.jface.dialogs.ProgressMonitorDialog; > import org.eclipse.jface.operation.IRunnableContext; >@@ -60,7 +61,7 @@ > > private static final int TELNET_DEFAULT_PORT = 23; // TODO Make configurable > private static final int TELNET_CONNECT_TIMEOUT = 60; //seconds - TODO: Make configurable >- private TelnetClient fTelnetClient = new TelnetClient(); >+ private TelnetClient fTelnetClient; > private SessionLostHandler fSessionLostHandler; > private InputStream in; > private PrintStream out; >@@ -109,72 +110,20 @@ > } > > protected void internalConnect(IProgressMonitor monitor) throws Exception { >- String host = getHostName(); >- String user = getUserId(); >- String password = ""; //$NON-NLS-1$ >- int status = ERROR_CODE; >- Exception nestedException = null; >+ > try { >- Activator.trace("Telnet Service: Connecting....."); //$NON-NLS-1$ >- fTelnetClient.connect(host, TELNET_DEFAULT_PORT); >- SystemSignonInformation ssi = getSignonInformation(); >- if (ssi != null) { >- password = ssi.getPassword(); >- } >- >- in = fTelnetClient.getInputStream(); >- out = new PrintStream(fTelnetClient.getOutputStream()); >- >- long millisToEnd = System.currentTimeMillis() + TELNET_CONNECT_TIMEOUT*1000; >- LoginThread checkLogin = new LoginThread(user, password); >- checkLogin.start(); >- while (checkLogin.isAlive() && System.currentTimeMillis()<millisToEnd) { >- if (monitor!=null) { >- monitor.worked(1); >- if (monitor.isCanceled()) { >- status = CONNECT_CANCELED; >- //Thread will be interrupted by sessionDisconnect() >- //checkLogin.interrupt(); >- break; >- } >- } >- Display d = Display.getCurrent(); >- if (d!=null) { >- while(d.readAndDispatch()) { >- //get next event if on dispatch thread >- } >- } >- checkLogin.join(500); >- } >- if (status != CONNECT_CANCELED) { >- status = checkLogin.getLoginStatus(); >- checkLogin.join(); >- } >- } catch (Exception e) { >- Activator.trace("Telnet Service failed: " + e.toString()); //$NON-NLS-1$ >- nestedException = e; >- } finally { >- if (status == CONNECT_CANCELED) { >- Activator.trace("Telnet Service: Canceled"); //$NON-NLS-1$ >- sessionDisconnect(); //will eventually destroy the LoginThread >- } else if (status == SUCCESS_CODE) { >+ >+ TelnetClient client = makeNewTelnetClient(monitor); >+ if( client != null ) { >+ fTelnetClient = client; > fSessionLostHandler = new SessionLostHandler(this); > notifyConnection(); >- Activator.trace("Telnet Service: Connected"); //$NON-NLS-1$ >- } else { >- Activator.trace("Telnet Service: Connect failed"); //$NON-NLS-1$ >- //TODO pass the nested exception as well as original prompts >- //from the remote side with the SystemMessageException for user diagnostics >- SystemMessage msg; >- if (nestedException!=null) { >- msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXCEPTION_OCCURRED); >- msg.makeSubstitution(nestedException); >- } else { >- msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_AUTH_FAILED); >- msg.makeSubstitution(getHost().getAliasName()); >- } >- internalDisconnect(null); >- throw new SystemMessageException(msg); >+ } >+ }catch( Exception e) { >+ >+ if( e instanceof SystemMessageException ) { >+ internalDisconnect( null ); >+ throw e; > } > } > } >@@ -265,11 +214,85 @@ > > // Fire comm event to signal state changed > notifyDisconnection(); >+ clearPassword(false,true); > } > > public TelnetClient getTelnetClient() { > return fTelnetClient; > } >+ >+ public TelnetClient makeNewTelnetClient( IProgressMonitor monitor ) throws Exception{ >+ >+ TelnetClient client = new TelnetClient(); >+ String host = getHostName(); >+ String user = getUserId(); >+ String password = ""; //$NON-NLS-1$ >+ int status = ERROR_CODE; >+ Exception nestedException = null; >+ try { >+ Activator.trace("Telnet Service: Connecting....."); //$NON-NLS-1$ >+ client.connect(host, TELNET_DEFAULT_PORT); >+ SystemSignonInformation ssi = getSignonInformation(); >+ if (ssi != null) { >+ password = ssi.getPassword(); >+ } >+ >+ in = client.getInputStream(); >+ out = new PrintStream(client.getOutputStream()); >+ >+ long millisToEnd = System.currentTimeMillis() + TELNET_CONNECT_TIMEOUT*1000; >+ LoginThread checkLogin = new LoginThread(user, password); >+ checkLogin.start(); >+ while (checkLogin.isAlive() && System.currentTimeMillis()<millisToEnd) { >+ if (monitor!=null) { >+ monitor.worked(1); >+ if (monitor.isCanceled()) { >+ status = CONNECT_CANCELED; >+ //Thread will be interrupted by sessionDisconnect() >+ //checkLogin.interrupt(); >+ break; >+ } >+ } >+ Display d = Display.getCurrent(); >+ if (d!=null) { >+ while(d.readAndDispatch()) { >+ //get next event if on dispatch thread >+ } >+ } >+ checkLogin.join(500); >+ } >+ if (status != CONNECT_CANCELED) { >+ status = checkLogin.getLoginStatus(); >+ checkLogin.join(); >+ } >+ } catch (Exception e) { >+ Activator.trace("Telnet Service failed: " + e.toString()); //$NON-NLS-1$ >+ nestedException = e; >+ } finally { >+ if (status == CONNECT_CANCELED) { >+ Activator.trace("Telnet Service: Canceled"); //$NON-NLS-1$ >+ sessionDisconnect(); //will eventually destroy the LoginThread >+ client = null; >+ } else if (status == SUCCESS_CODE) { >+ Activator.trace("Telnet Service: Connected"); //$NON-NLS-1$ >+ } else { >+ Activator.trace("Telnet Service: Connect failed"); //$NON-NLS-1$ >+ //TODO pass the nested exception as well as original prompts >+ //from the remote side with the SystemMessageException for user diagnostics >+ SystemMessage msg; >+ if (nestedException!=null) { >+ msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXCEPTION_OCCURRED); >+ msg.makeSubstitution(nestedException); >+ } else { >+ msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_AUTH_FAILED); >+ msg.makeSubstitution(getHost().getAliasName()); >+ } >+ client = null; >+ throw new SystemMessageException(msg); >+ } >+ } >+ return client; >+ } > > /** > * Handle session-lost events. This is generic for any sort of connector >#P org.eclipse.rse.services.telnet >Index: src/org/eclipse/rse/internal/services/telnet/shell/TelnetHostShell.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/shell/TelnetHostShell.java,v >retrieving revision 1.2 >diff -u -r1.2 TelnetHostShell.java >--- src/org/eclipse/rse/internal/services/telnet/shell/TelnetHostShell.java 11 May 2007 13:30:48 -0000 1.2 >+++ src/org/eclipse/rse/internal/services/telnet/shell/TelnetHostShell.java 6 Jun 2007 12:54:51 -0000 >@@ -25,6 +25,7 @@ > import java.util.regex.Pattern; > > import org.apache.commons.net.telnet.TelnetClient; >+import org.eclipse.core.runtime.NullProgressMonitor; > import org.eclipse.rse.internal.services.telnet.ITelnetSessionProvider; > import org.eclipse.rse.services.clientserver.PathUtility; > import org.eclipse.rse.services.shells.AbstractHostShell; >@@ -39,15 +40,17 @@ > private TelnetShellOutputReader fStdoutHandler; > private TelnetShellOutputReader fStderrHandler; > private TelnetShellWriterThread fShellWriter; >+ private TelnetClient fTelnetClient; > > public TelnetHostShell(ITelnetSessionProvider sessionProvider, String initialWorkingDirectory, String commandToRun, String encoding, String[] environment) { > try { > fSessionProvider = sessionProvider; > >+ fTelnetClient = fSessionProvider.makeNewTelnetClient( new NullProgressMonitor()); > >- fStdoutHandler = new TelnetShellOutputReader(this, new BufferedReader(new InputStreamReader(sessionProvider.getTelnetClient().getInputStream())), false); >+ fStdoutHandler = new TelnetShellOutputReader(this, new BufferedReader(new InputStreamReader(fTelnetClient.getInputStream())), false); > fStderrHandler = new TelnetShellOutputReader(this, null,true); >- OutputStream outputStream = sessionProvider.getTelnetClient().getOutputStream(); >+ OutputStream outputStream = fTelnetClient.getOutputStream(); > //TODO check if encoding or command to execute needs to be considered > //If a command is given, it might be possible to do without a Thread > //Charset cs = Charset.forName(encoding); >@@ -85,11 +88,10 @@ > try { > //TODO disconnect should better be done via the ConnectorService!! > //Because like we do it here, the connector service is not notified! >- TelnetClient client = fSessionProvider.getTelnetClient(); >- if (client!=null) { >- synchronized(client) { >- if (client.isConnected()) >- client.disconnect(); >+ if (fTelnetClient!=null) { >+ synchronized(fTelnetClient) { >+ if (fTelnetClient.isConnected()) >+ fTelnetClient.disconnect(); > } > } > } catch (IOException e) { >@@ -106,14 +108,13 @@ > } > > public boolean isActive() { >- TelnetClient client = fSessionProvider.getTelnetClient(); >- if (client!=null ) { >+ if (fTelnetClient!=null ) { > return true; > } > // shell is not active: check for session lost > exit(); > >- if (client!=null && !client.isConnected()) { >+ if (fTelnetClient!=null && !fTelnetClient.isConnected()) { > fSessionProvider.handleSessionLost(); > } > return false; >Index: src/org/eclipse/rse/internal/services/telnet/ITelnetSessionProvider.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/ITelnetSessionProvider.java,v >retrieving revision 1.1 >diff -u -r1.1 ITelnetSessionProvider.java >--- src/org/eclipse/rse/internal/services/telnet/ITelnetSessionProvider.java 11 May 2007 09:28:26 -0000 1.1 >+++ src/org/eclipse/rse/internal/services/telnet/ITelnetSessionProvider.java 6 Jun 2007 12:54:50 -0000 >@@ -17,11 +17,14 @@ > package org.eclipse.rse.internal.services.telnet; > > import org.apache.commons.net.telnet.TelnetClient; >+import org.eclipse.core.runtime.IProgressMonitor; > > public interface ITelnetSessionProvider { > > public TelnetClient getTelnetClient(); > >+ public TelnetClient makeNewTelnetClient( IProgressMonitor monitor) throws Exception ; >+ > /* Inform the connectorService that a session has been lost. */ > public void handleSessionLost(); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 187301
:
67796
|
68766
|
70316
|
72503