mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 06:32:10 +02:00
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
This commit is contained in:
parent
08074f77aa
commit
e6bec45296
1 changed files with 26 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue