Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ptp-dev] Problem with SSHTargetControl.create(IProgressMonitor monitor)

If this is still a problem, please open a bug.

Thanks,

Greg

On Sep 25, 2008, at 3:03 AM, 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


Back to the top