1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 02:36:01 +02:00

Fix local command proxy

Was broken by d5cb7731db

Change-Id: I26ec14d832150d20dfefa19b614299a495897bf5
This commit is contained in:
Roland Schulz 2015-04-01 17:23:25 -04:00
parent a977d9c6b6
commit f65b1837ed
2 changed files with 83 additions and 83 deletions

View file

@ -24,8 +24,8 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.remote.core.IRemoteProcessService;
import org.eclipse.remote.core.IRemoteProcess; import org.eclipse.remote.core.IRemoteProcess;
import org.eclipse.remote.core.IRemoteProcessService;
import org.eclipse.remote.core.IRemoteServicesManager; import org.eclipse.remote.core.IRemoteServicesManager;
import org.eclipse.remote.core.exception.RemoteConnectionException; import org.eclipse.remote.core.exception.RemoteConnectionException;
import org.eclipse.remote.internal.jsch.core.messages.Messages; import org.eclipse.remote.internal.jsch.core.messages.Messages;
@ -76,7 +76,8 @@ public class JSchConnectionProxyFactory {
@Override @Override
public void connect(SocketFactory socket_factory, String host, int port, int timeout) throws IOException { public void connect(SocketFactory socket_factory, String host, int port, int timeout) throws IOException {
assert !connectCalled : "connect should only be called once"; //$NON-NLS-1$ assert !connectCalled : "connect should only be called once"; //$NON-NLS-1$
try { connectCalled = true;
if (timeout == 0) { if (timeout == 0) {
timeout = 10000; // default to 10s timeout = 10000; // default to 10s
} }
@ -85,17 +86,14 @@ public class JSchConnectionProxyFactory {
SubMonitor subMon = SubMonitor.convert(monitor, waitSteps * 2); SubMonitor subMon = SubMonitor.convert(monitor, waitSteps * 2);
final SubMonitor childMon = subMon.newChild(waitSteps); final SubMonitor childMon = subMon.newChild(waitSteps);
if (connection == null) { if (connection != null) {
IRemoteServicesManager manager = Activator.getService(IRemoteServicesManager.class);
connection = (JSchConnection) manager.getLocalConnectionType().getConnections().get(0);
}
// Open connection if it isn't already opened // Open connection if it isn't already opened
try { try {
connection.openMinimal(childMon); connection.openMinimal(childMon);
} catch (RemoteConnectionException e) { } catch (RemoteConnectionException e) {
throw new IOException(e); throw new IOException(e);
} }
}
subMon.setWorkRemaining(waitSteps); subMon.setWorkRemaining(waitSteps);
// Start command // Start command
@ -103,10 +101,15 @@ public class JSchConnectionProxyFactory {
command = command.replace("%p", Integer.toString(port)); //$NON-NLS-1$ command = command.replace("%p", Integer.toString(port)); //$NON-NLS-1$
List<String> cmd = new ArgumentParser(command).getTokenList(); List<String> cmd = new ArgumentParser(command).getTokenList();
JSchProcessBuilder processBuilder = (JSchProcessBuilder) connection.getRemoteConnection()
.getService(IRemoteProcessService.class).getProcessBuilder(cmd); if (connection != null) {
JSchProcessBuilder processBuilder = (JSchProcessBuilder) connection.getProcessBuilder(cmd);
processBuilder.setPreamble(false); processBuilder.setPreamble(false);
process = processBuilder.start(); process = processBuilder.start();
} else {
process = Activator.getService(IRemoteServicesManager.class).getLocalConnectionType().getConnections().get(0).
getService(IRemoteProcessService.class).getProcessBuilder(cmd).start();
}
// Wait on command to produce stdout output // Wait on command to produce stdout output
long endTime = System.currentTimeMillis() + timeout; long endTime = System.currentTimeMillis() + timeout;
@ -162,9 +165,6 @@ public class JSchConnectionProxyFactory {
} }
}; };
}.start(); }.start();
} finally {
connectCalled = true;
}
} }
/* /*

View file

@ -91,7 +91,7 @@ public class JSchProcessBuilder extends AbstractRemoteProcessBuilder {
@Override @Override
public IRemoteProcess start(int flags) throws IOException { public IRemoteProcess start(int flags) throws IOException {
if (!fConnection.isOpen()) { if (!fConnection.hasOpenSession()) {
throw new IOException(Messages.JSchProcessBuilder_Connection_is_not_open); throw new IOException(Messages.JSchProcessBuilder_Connection_is_not_open);
} }