Skip to main content
summaryrefslogtreecommitdiffstats
path: root/cross
diff options
context:
space:
mode:
authorAlvaro Sanchez-Leon2016-05-19 16:32:20 -0400
committerAlvaro Sanchez-Leon2016-05-24 11:07:17 -0400
commite6bec452967a7bd134769703db0359b116769d78 (patch)
treefb95742f060a6a19666440eadea66f43249edf16 /cross
parent08074f77aa5a23dfce35d38ae595271836d7f803 (diff)
downloadorg.eclipse.cdt-e6bec452967a7bd134769703db0359b116769d78.tar.gz
org.eclipse.cdt-e6bec452967a7bd134769703db0359b116769d78.tar.xz
org.eclipse.cdt-e6bec452967a7bd134769703db0359b116769d78.zip
Bug 452356 - C/C++ remote launch uses o.e.remote - wait for file permission change
When uploading a file to a remote system, the file permissions are updated, however the process taking care of it may not have completed this task before the application tries to use it. This change forces the calling thread to wait for Max 1 sec for it to complete, If the process task takes longer an exception is thrown so the application can provide a meaningful message to the user. A second fix is provided in: execCmdInRemoteShell So this method now makes sure that the remote connection is opened before executing commands over the remote shell. Change-Id: Ibe8bd2709e1b1f446e1f74aa8a3df424ac7fa650
Diffstat (limited to 'cross')
-rw-r--r--cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/RemoteHelper.java28
1 files changed, 26 insertions, 2 deletions
diff --git a/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/RemoteHelper.java b/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/RemoteHelper.java
index 153c174fa4..bc389c24cb 100644
--- a/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/RemoteHelper.java
+++ b/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/RemoteHelper.java
@@ -17,7 +17,9 @@ package org.eclipse.cdt.launch.remote;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.internal.launch.remote.Activator;
@@ -113,9 +115,28 @@ public class RemoteHelper {
localFile.copy(remoteFile, EFS.OVERWRITE, monitor);
// Need to change the permissions to match the original file
// permissions because of a bug in upload
- remoteShellExec(
+ Process p = remoteShellExec(
config,
"", "chmod", "+x " + spaceEscapify(remoteExePath), new SubProgressMonitor(monitor, 5)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ // Wait if necessary for the permission change
+ try {
+ int timeOut = 10;
+ boolean exited = p.waitFor(timeOut, TimeUnit.SECONDS);
+
+ if (!exited) {
+ Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR,
+ "Failed to change file permissions in the remote system, path: " + remoteExePath, //$NON-NLS-1$
+ null);
+ throw new CoreException(status);
+ }
+ } catch (InterruptedException e) {
+ Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR,
+ "Interrupted while changing file permissions in the remote system, path: " //$NON-NLS-1$
+ + remoteExePath,
+ e);
+ throw new CoreException(status);
+ }
} catch (CoreException e) {
abort(Messages.RemoteRunLaunchDelegate_6, e,
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
@@ -200,7 +221,10 @@ public class RemoteHelper {
if (!prelaunchCmd.trim().equals("")) //$NON-NLS-1$
remoteCommand = prelaunchCmd + CMD_DELIMITER + remoteCommand;
- IRemoteConnection conn = getCurrentConnection(config);
+ IRemoteConnection conn = getCurrentConnection(config);
+ if (!conn.isOpen()) {
+ conn.open(monitor);
+ }
IRemoteCommandShellService shellService = conn.getService(IRemoteCommandShellService.class);
IRemoteProcess p = null;

Back to the top