1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 06:45:43 +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
id="org.eclipse.rse.telnet"
label="%featureName"
version="2.0.0.qualifier"
version="2.0.1.qualifier"
provider-name="%providerName"
plugin="org.eclipse.rse.services.telnet">
@ -26,15 +26,10 @@
<requires>
<import plugin="org.eclipse.core.runtime"/>
<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.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.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.files.core" version="2.0.0" match="compatible"/>
<import plugin="org.eclipse.rse.ui" version="2.0.0" match="compatible"/>
</requires>

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
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-Localization: plugin
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
* Martin Oberhuber (Wind River) - [187218] Fix error reporting for connect()
* 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;
@ -67,8 +68,6 @@ public class TelnetConnectorService extends StandardConnectorService implements
private static final int TELNET_CONNECT_TIMEOUT = 60; //seconds - TODO: Make configurable
private List fTelnetClients = new ArrayList();
private SessionLostHandler fSessionLostHandler;
private InputStream in;
private PrintStream out;
private IPropertySet telnetPropertySet = null;
private static final int ERROR_CODE = 100; // filed error code
private static final int SUCCESS_CODE = 150; // login pass code
@ -148,11 +147,8 @@ public class TelnetConnectorService extends StandardConnectorService implements
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);
LoginThread checkLogin = new LoginThread(user, password,client.getInputStream(),new PrintStream( client.getOutputStream() ));
checkLogin.start();
while (checkLogin.isAlive() && System.currentTimeMillis()<millisToEnd) {
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 {
char lastChar = pattern.charAt(pattern.length() - 1);
StringBuffer sb = new StringBuffer();
@ -260,7 +256,7 @@ public class TelnetConnectorService extends StandardConnectorService implements
return CONNECT_CLOSED;
}
public void write(String value) {
public void write(String value,PrintStream out) {
try {
out.println(value);
out.flush();
@ -498,10 +494,14 @@ public class TelnetConnectorService extends StandardConnectorService implements
private String username;
private String password;
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.password = password;
this.in = in;
this.out = out;
}
public void run() {
@ -519,19 +519,19 @@ public class TelnetConnectorService extends StandardConnectorService implements
if (Boolean.valueOf(login_required).booleanValue()) {
status = SUCCESS_CODE;
if (login_prompt != null && login_prompt.length() > 0) {
status = readUntil(login_prompt);
write(username);
status = readUntil(login_prompt,this.in);
write(username,this.out);
}
if (status == SUCCESS_CODE && password_prompt != null && password_prompt.length() > 0) {
status = readUntil(password_prompt);
write(password);
status = readUntil(password_prompt,this.in);
write(password,this.out);
}
if (status == SUCCESS_CODE && command_prompt != null && command_prompt.length() > 0) {
status = readUntil(command_prompt);
status = readUntil(command_prompt,this.in);
}
} else {
if (command_prompt != null && command_prompt.length() > 0) {
status = readUntil(command_prompt);
status = readUntil(command_prompt,this.in);
}
}
}