1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 14:55:41 +02:00

[194464] fix create multiple telnet shells quickly

This commit is contained in:
Martin Oberhuber 2007-07-04 15:56:47 +00:00
parent d60bfabeaa
commit 5cc30b5522
3 changed files with 17 additions and 22 deletions

View file

@ -2,7 +2,7 @@
<feature <feature
id="org.eclipse.rse.telnet" id="org.eclipse.rse.telnet"
label="%featureName" label="%featureName"
version="2.0.0.qualifier" version="2.0.1.qualifier"
provider-name="%providerName" provider-name="%providerName"
plugin="org.eclipse.rse.services.telnet"> plugin="org.eclipse.rse.services.telnet">
@ -26,15 +26,10 @@
<requires> <requires>
<import plugin="org.eclipse.core.runtime"/> <import plugin="org.eclipse.core.runtime"/>
<import plugin="org.eclipse.ui"/> <import plugin="org.eclipse.ui"/>
<import plugin="org.apache.commons.net" version="1.4.1" match="compatible"/>
<import plugin="org.apache.oro" version="2.0.8" match="equivalent"/>
<import plugin="org.eclipse.rse.core" version="2.0.0" match="compatible"/> <import plugin="org.eclipse.rse.core" version="2.0.0" match="compatible"/>
<import plugin="org.eclipse.rse.connectorservice.telnet" version="1.0.0" match="compatible"/>
<import plugin="org.eclipse.rse.services.telnet" version="1.0.0" match="compatible"/>
<import plugin="org.eclipse.rse.services" version="2.0.0" match="compatible"/> <import plugin="org.eclipse.rse.services" version="2.0.0" match="compatible"/>
<import plugin="org.eclipse.rse.shells.ui" version="2.0.0" match="compatible"/> <import plugin="org.eclipse.rse.shells.ui" version="2.0.0" match="compatible"/>
<import plugin="org.eclipse.rse.subsystems.shells.core" version="2.0.0" match="compatible"/> <import plugin="org.eclipse.rse.subsystems.shells.core" version="2.0.0" match="compatible"/>
<import plugin="org.eclipse.rse.subsystems.files.core" version="2.0.0" match="compatible"/>
<import plugin="org.eclipse.rse.ui" version="2.0.0" match="compatible"/> <import plugin="org.eclipse.rse.ui" version="2.0.0" match="compatible"/>
</requires> </requires>

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: %pluginName Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.rse.connectorservice.telnet;singleton:=true Bundle-SymbolicName: org.eclipse.rse.connectorservice.telnet;singleton:=true
Bundle-Version: 1.0.0.qualifier Bundle-Version: 1.0.1.qualifier
Bundle-Activator: org.eclipse.rse.internal.connectorservice.telnet.Activator Bundle-Activator: org.eclipse.rse.internal.connectorservice.telnet.Activator
Bundle-Localization: plugin Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime, Require-Bundle: org.eclipse.core.runtime,

View file

@ -15,6 +15,7 @@
* Sheldon D'souza (Celunite) - [186570] handle invalid user id and password more gracefully * Sheldon D'souza (Celunite) - [186570] handle invalid user id and password more gracefully
* Martin Oberhuber (Wind River) - [187218] Fix error reporting for connect() * Martin Oberhuber (Wind River) - [187218] Fix error reporting for connect()
* Sheldon D'souza (Celunite) - [187301] support multiple telnet shells * Sheldon D'souza (Celunite) - [187301] support multiple telnet shells
* Sheldon D'souza (Celunite) - [194464] fix create multiple telnet shells quickly
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.internal.connectorservice.telnet; package org.eclipse.rse.internal.connectorservice.telnet;
@ -67,8 +68,6 @@ public class TelnetConnectorService extends StandardConnectorService implements
private static final int TELNET_CONNECT_TIMEOUT = 60; //seconds - TODO: Make configurable private static final int TELNET_CONNECT_TIMEOUT = 60; //seconds - TODO: Make configurable
private List fTelnetClients = new ArrayList(); private List fTelnetClients = new ArrayList();
private SessionLostHandler fSessionLostHandler; private SessionLostHandler fSessionLostHandler;
private InputStream in;
private PrintStream out;
private IPropertySet telnetPropertySet = null; private IPropertySet telnetPropertySet = null;
private static final int ERROR_CODE = 100; // filed error code private static final int ERROR_CODE = 100; // filed error code
private static final int SUCCESS_CODE = 150; // login pass code private static final int SUCCESS_CODE = 150; // login pass code
@ -148,11 +147,8 @@ public class TelnetConnectorService extends StandardConnectorService implements
password = ssi.getPassword(); password = ssi.getPassword();
} }
in = client.getInputStream();
out = new PrintStream(client.getOutputStream());
long millisToEnd = System.currentTimeMillis() + TELNET_CONNECT_TIMEOUT*1000; long millisToEnd = System.currentTimeMillis() + TELNET_CONNECT_TIMEOUT*1000;
LoginThread checkLogin = new LoginThread(user, password); LoginThread checkLogin = new LoginThread(user, password,client.getInputStream(),new PrintStream( client.getOutputStream() ));
checkLogin.start(); checkLogin.start();
while (checkLogin.isAlive() && System.currentTimeMillis()<millisToEnd) { while (checkLogin.isAlive() && System.currentTimeMillis()<millisToEnd) {
if (monitor!=null) { if (monitor!=null) {
@ -231,7 +227,7 @@ public class TelnetConnectorService extends StandardConnectorService implements
} }
} }
public int readUntil(String pattern) { public int readUntil(String pattern,InputStream in) {
try { try {
char lastChar = pattern.charAt(pattern.length() - 1); char lastChar = pattern.charAt(pattern.length() - 1);
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
@ -260,7 +256,7 @@ public class TelnetConnectorService extends StandardConnectorService implements
return CONNECT_CLOSED; return CONNECT_CLOSED;
} }
public void write(String value) { public void write(String value,PrintStream out) {
try { try {
out.println(value); out.println(value);
out.flush(); out.flush();
@ -498,10 +494,14 @@ public class TelnetConnectorService extends StandardConnectorService implements
private String username; private String username;
private String password; private String password;
private int status = SUCCESS_CODE; private int status = SUCCESS_CODE;
private InputStream in;
private PrintStream out;
public LoginThread(String username, String password) { public LoginThread(String username, String password,InputStream in,PrintStream out) {
this.username = username; this.username = username;
this.password = password; this.password = password;
this.in = in;
this.out = out;
} }
public void run() { public void run() {
@ -519,19 +519,19 @@ public class TelnetConnectorService extends StandardConnectorService implements
if (Boolean.valueOf(login_required).booleanValue()) { if (Boolean.valueOf(login_required).booleanValue()) {
status = SUCCESS_CODE; status = SUCCESS_CODE;
if (login_prompt != null && login_prompt.length() > 0) { if (login_prompt != null && login_prompt.length() > 0) {
status = readUntil(login_prompt); status = readUntil(login_prompt,this.in);
write(username); write(username,this.out);
} }
if (status == SUCCESS_CODE && password_prompt != null && password_prompt.length() > 0) { if (status == SUCCESS_CODE && password_prompt != null && password_prompt.length() > 0) {
status = readUntil(password_prompt); status = readUntil(password_prompt,this.in);
write(password); write(password,this.out);
} }
if (status == SUCCESS_CODE && command_prompt != null && command_prompt.length() > 0) { if (status == SUCCESS_CODE && command_prompt != null && command_prompt.length() > 0) {
status = readUntil(command_prompt); status = readUntil(command_prompt,this.in);
} }
} else { } else {
if (command_prompt != null && command_prompt.length() > 0) { if (command_prompt != null && command_prompt.length() > 0) {
status = readUntil(command_prompt); status = readUntil(command_prompt,this.in);
} }
} }
} }