1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-19 22:25:52 +02:00

[199243] Renaming a file in an FTP-based EFS folder hangs all of Eclipse

This commit is contained in:
Javier Montalvo Orus 2007-08-10 12:51:04 +00:00
parent 292d091904
commit 4bdb33cd8e

View file

@ -57,6 +57,7 @@
* Martin Oberhuber (Wind River) - [198645] Fix case sensitivity issues * Martin Oberhuber (Wind River) - [198645] Fix case sensitivity issues
* Martin Oberhuber (Wind River) - [192610] Fix thread safety for delete(), upload(), setReadOnly() operations * Martin Oberhuber (Wind River) - [192610] Fix thread safety for delete(), upload(), setReadOnly() operations
* Martin Oberhuber (Wind River) - [199548] Avoid touching files on setReadOnly() if unnecessary * Martin Oberhuber (Wind River) - [199548] Avoid touching files on setReadOnly() if unnecessary
* Javier Montalvo Orus (Symbian) - [199243] Renaming a file in an FTP-based EFS folder hangs all of Eclipse
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.internal.services.files.ftp; package org.eclipse.rse.internal.services.files.ftp;
@ -165,6 +166,7 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
public void close() throws IOException { public void close() throws IOException {
super.close(); super.close();
client.completePendingCommand(); client.completePendingCommand();
client.logout();
} }
} }
@ -200,6 +202,7 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
public void close() throws IOException { public void close() throws IOException {
super.close(); super.close();
client.completePendingCommand(); client.completePendingCommand();
client.logout();
} }
} }
@ -412,6 +415,44 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
return _ftpClient; return _ftpClient;
} }
/**
* Clones the main FTP client connection, providing a separate client connected to the FTP server.
*
* @param isBinary true if the FTPClient has to be using binary mode for data transfer, otherwise ASCII mode will be used
* @return A new commons.net FTPClient connected to the same server. After usage it has to be disconnected.
* @throws IOException
*/
private FTPClient cloneFTPClient(boolean isBinary) throws IOException
{
FTPClient ftpClient = new FTPClient();
ftpClient.connect(_ftpClient.getRemoteAddress());
ftpClient.login(_userId,_password);
if (_clientConfigProxy != null) {
ftpClient.configure(_clientConfigProxy.getFTPClientConfig());
} else {
// UNIX parsing by default if no suitable parser found
ftpClient.configure(new FTPClientConfig(FTPClientConfig.SYST_UNIX));
}
if (_isPassiveDataConnectionMode) {
ftpClient.enterLocalPassiveMode();
}
if (isBinary) {
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
} else {
ftpClient.setFileType(FTP.ASCII_FILE_TYPE);
}
ftpClient.registerSpyStream(_ftpLoggingOutputStream);
return ftpClient;
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.rse.services.files.IFileService#getFile(String, String, IProgressMonitor) * @see org.eclipse.rse.services.files.IFileService#getFile(String, String, IProgressMonitor)
@ -1305,29 +1346,15 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
InputStream stream = null; InputStream stream = null;
if(_commandMutex.waitForLock(monitor, Long.MAX_VALUE)) try {
{ FTPClient ftpClient = cloneFTPClient(isBinary);
try { ftpClient.changeWorkingDirectory(remoteParent);
FTPClient ftpClient = getFTPClient(); stream = new FTPBufferedInputStream(ftpClient.retrieveFileStream(remoteFile), ftpClient);
ftpClient.changeWorkingDirectory(remoteParent);
setFileType(isBinary);
stream = new FTPBufferedInputStream(ftpClient.retrieveFileStream(remoteFile), ftpClient);
} }
catch (Exception e) { catch (Exception e) {
throw new RemoteFileIOException(e); throw new RemoteFileIOException(e);
}finally {
//TODO I am not 100% sure but I _think_ that the _commandMutex
//may only be released once reading the stream is complete,
//since in FTPBufferedInputStream.close() a pending command
//is being sent.
//After all, the safer solution would be to have a separate
//FTP client connection to the remote for the download, such
//that dir channel remains free. See bug #198636
_commandMutex.release();
} }
} else {
throw new RemoteFileCancelledException();
}
return stream; return stream;
} }
@ -1343,20 +1370,14 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
OutputStream stream = null; OutputStream stream = null;
if(_commandMutex.waitForLock(monitor, Long.MAX_VALUE)) try {
{ FTPClient ftpClient = cloneFTPClient(isBinary);
try { clearCache(remoteParent);
FTPClient ftpClient = getFTPClient(); ftpClient.changeWorkingDirectory(remoteParent);
clearCache(remoteParent); stream = new FTPBufferedOutputStream(ftpClient.storeFileStream(remoteFile), ftpClient);
ftpClient.changeWorkingDirectory(remoteParent); }
setFileType(isBinary); catch (Exception e) {
stream = new FTPBufferedOutputStream(ftpClient.storeFileStream(remoteFile), ftpClient); throw new RemoteFileIOException(e);
}
catch (Exception e) {
throw new RemoteFileIOException(e);
}finally {
_commandMutex.release();
}
} }
return stream; return stream;