Hi Hong Chang,
I wonder if you are using targetControl correctly(monitor).
1) There is a possible scenario where the user might have a ssh login
without a password. It is allowed by the ssh specification, although
empty password uses to be disabled on the ssh server default
configuration. And the remote tools dialog complies to the
specification. Therefore, one cannot force the user to fillout a
password on the dialog. Nevertheless, the Cell IDE uses the empty
password scenario for a simulator target
environment, where security of the connection to the simulator is not
an issues.
2) There is a limitation on the underlying ssh library that remote
tools uses to connect to the remote machine. It does not return status
if the connection failed due timeout or any other error (eg. wrong
password). Therefore, often it makes sense to try to connect again.
However, the user has to option to cancel and interrupt the retries, as
you can see in the code. Eventually the ssh implementation will
eventually provide the missing information, so that we can handle
failure in a smarter way.
If you are not able to cancel the targetControl correctly(monitor), I
suspect that you are blocking the UI thread, preventing eclipse from
showing up the progress dialog and sending cancel events back to the
job.
Best regards,
Daniel Felix Ferber
Hong Chang Lin wrote:
I found a problem when connecting to a remote host with SSH:
If there is a target control which misses the password (when creating
the target control, the config create dialog allows me to finish even
missing password), and invokes the targetControl.create(monitor)
in my wroten codes. Then, the Eclipse workbench will hang up there, I
can't do nothing unless I kill the Eclipse and restart again. I wrap
the targetControl.create(monitor) in an Eclipse job, and
block there to wait it to be finished, so no progress dialog pops up
and by no means I can cancel it from UI.
I investigated the codes, and thought the root causes lie in two places:
1. As mentioned before, the config create dialog should not allow user
to finish without filling in password
2. In the method SSHTargetControl.create(IProgressMonitor monitor),
there is a while loop that will never ends up if the connection is
failed (which is caused by missing password), and by no means
cancelling from UI
Can we at least fix the 1st problem? And think about the scenario in
which SSHTargetControl.create(IProgressMonitor monitor) is invoked as
an API, no UI operation involed.
public boolean create(IProgressMonitor monitor) throws CoreException {
Assert.isNotNull(sshParameters, "missing
ssh parameters");
while (true) {
try {
if
(monitor.isCanceled()) {
disconnect();
throw new CoreException(new
Status(IStatus.ERROR, getPluginId(), 0, "Connection to target canceled", null));
}
connect();
if
(monitor.isCanceled()) {
disconnect();
throw new CoreException(new
Status(IStatus.ERROR, getPluginId(), 0, "Connection to target canceled", null));
}
return true;
} catch
(RemoteConnectionException e) {
monitor.subTask("Failed: " +
e.getMessage());
/*
* Ignore failure,
unfortunately, it is not possible to know the reason.
*/
disconnect();
}
try {
Thread.sleep(2000);
} catch
(InterruptedException e) {
disconnect();
throw new CoreException(new
Status(IStatus.CANCEL, getPluginId(), 0, "Connection to target canceled", null));
}
}
}
Best Regards,
------
Hongchang Lin
_______________________________________________
ptp-dev mailing list
ptp-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ptp-dev
|