Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 78377 Details for
Bug 203306
[ftp] Deadlock when comparing two files on FTP
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch fixing the issue for AccumulatingProgressMonitor
patch203306_deadlock_ftp_compare.diff.txt (text/plain), 7.78 KB, created by
Martin Oberhuber
on 2007-09-13 15:53:45 EDT
(
hide
)
Description:
Patch fixing the issue for AccumulatingProgressMonitor
Filename:
MIME Type:
Creator:
Martin Oberhuber
Created:
2007-09-13 15:53:45 EDT
Size:
7.78 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rse.services.files.ftp >Index: src/org/eclipse/rse/internal/services/files/ftp/FTPService.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/internal/services/files/ftp/FTPService.java,v >retrieving revision 1.36 >diff -u -r1.36 FTPService.java >--- src/org/eclipse/rse/internal/services/files/ftp/FTPService.java 10 Aug 2007 13:17:27 -0000 1.36 >+++ src/org/eclipse/rse/internal/services/files/ftp/FTPService.java 13 Sep 2007 19:46:30 -0000 >@@ -58,6 +58,7 @@ > * 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 > * Javier Montalvo Orus (Symbian) - [199243] Renaming a file in an FTP-based EFS folder hangs all of Eclipse >+ * Martin Oberhuber (Wind River) - [203306] Fix Deadlock comparing two files on FTP > ********************************************************************************/ > > package org.eclipse.rse.internal.services.files.ftp; >@@ -687,57 +688,65 @@ > else{ > monitor = new NullProgressMonitor(); > } >- >- if(_commandMutex.waitForLock(monitor, Long.MAX_VALUE)) >- { >- try >+ >+ MyProgressMonitor progressMonitor = new MyProgressMonitor(monitor); >+ progressMonitor.init(0, localFile.getName(), remoteFile, localFile.length()); >+ FileInputStream input = null; >+ OutputStream output = null; >+ >+ try { >+ if(_commandMutex.waitForLock(monitor, Long.MAX_VALUE)) > { >- MyProgressMonitor progressMonitor = new MyProgressMonitor(monitor); >- >- FTPClient ftpClient = getFTPClient(); >- clearCache(remoteParent); >- ftpClient.changeWorkingDirectory(remoteParent); >- setFileType(isBinary); >- >- FileInputStream input = new FileInputStream(localFile); >- OutputStream output = ftpClient.storeFileStream(remoteFile); >- >- progressMonitor.init(0, localFile.getName(), remoteFile, localFile.length()); >- long bytes=0; >- byte[] buffer = new byte[4096]; >- >- int readCount; >- while((readCount = input.read(buffer)) > 0) >+ try > { >- bytes+=readCount; >- output.write(buffer, 0, readCount); >- progressMonitor.count(readCount); >- if (monitor!=null){ >- if (monitor.isCanceled()) { >- retValue = false; >- break; >- } >+ FTPClient ftpClient = getFTPClient(); >+ clearCache(remoteParent); >+ ftpClient.changeWorkingDirectory(remoteParent); >+ setFileType(isBinary); >+ >+ input = new FileInputStream(localFile); >+ output = ftpClient.storeFileStream(remoteFile); >+ if (output!=null) { >+ long bytes=0; >+ byte[] buffer = new byte[4096]; >+ >+ int readCount; >+ while((readCount = input.read(buffer)) > 0) >+ { >+ bytes+=readCount; >+ output.write(buffer, 0, readCount); >+ progressMonitor.count(readCount); >+ if (monitor!=null){ >+ if (monitor.isCanceled()) { >+ retValue = false; >+ break; >+ } >+ } >+ } >+ if (retValue) { >+ output.flush(); >+ } >+ ftpClient.completePendingCommand(); >+ } else { >+ throw new Exception(ftpClient.getReplyString()); >+ } >+ if(retValue==false) { >+ ftpClient.deleteFile(remoteFile); > } > } >- >- input.close(); >- output.flush(); >- output.close(); >- >- ftpClient.completePendingCommand(); >- >- if(retValue==false) { >- ftpClient.deleteFile(remoteFile); >- } >- >- progressMonitor.end(); >+ finally { >+ _commandMutex.release(); >+ try { >+ if (input!=null) input.close(); >+ } finally { >+ if (output!=null) output.close(); >+ } >+ } > } >- catch (Exception e) >- { >- throw new RemoteFileIOException(e); >- } finally { >- _commandMutex.release(); >- } >+ } catch(Exception e) { >+ throw new RemoteFileIOException(e); >+ } finally { >+ progressMonitor.end(); > } > > return retValue; >@@ -800,78 +809,77 @@ > } > > IHostFile remoteHostFile = getFile(remoteParent, remoteFile, monitor); >+ MyProgressMonitor progressMonitor = new MyProgressMonitor(monitor); >+ progressMonitor.init(0, remoteFile, localFile.getName(), remoteHostFile.getSize()); >+ OutputStream output = null; >+ InputStream input = null; > >- if(_commandMutex.waitForLock(monitor, Long.MAX_VALUE)) >- { >- try >+ try { >+ if(_commandMutex.waitForLock(monitor, Long.MAX_VALUE)) > { >- FTPClient ftpClient = getFTPClient(); >- >- MyProgressMonitor progressMonitor = new MyProgressMonitor(monitor); >- >- OutputStream output = null; >- InputStream input = null; >- >- ftpClient.changeWorkingDirectory(remoteParent); >- setFileType(isBinary); >- >- input = ftpClient.retrieveFileStream(remoteFile); >- >- if(input != null) >+ try > { >- if (!localFile.exists()) >+ FTPClient ftpClient = getFTPClient(); >+ ftpClient.changeWorkingDirectory(remoteParent); >+ setFileType(isBinary); >+ >+ input = ftpClient.retrieveFileStream(remoteFile); >+ >+ if(input != null) > { >- File localParentFile = localFile.getParentFile(); >- if (!localParentFile.exists()) >+ if (!localFile.exists()) >+ { >+ File localParentFile = localFile.getParentFile(); >+ if (!localParentFile.exists()) >+ { >+ localParentFile.mkdirs(); >+ } >+ localFile.createNewFile(); >+ } >+ >+ output = new FileOutputStream(localFile); >+ byte[] buffer = new byte[4096]; >+ int readCount; >+ while((readCount = input.read(buffer)) > 0) > { >- localParentFile.mkdirs(); >+ output.write(buffer, 0, readCount); >+ progressMonitor.count(readCount); >+ if (monitor!=null){ >+ if (monitor.isCanceled()) { >+ retValue = false; >+ break; >+ } >+ } > } >- localFile.createNewFile(); >+ >+ if (retValue) output.flush(); >+ >+ ftpClient.completePendingCommand(); >+ > } >- >- output = new FileOutputStream(localFile); >- progressMonitor.init(0, remoteFile, localFile.getName(), remoteHostFile.getSize()); >- byte[] buffer = new byte[4096]; >- int readCount; >- while((readCount = input.read(buffer)) > 0) >+ else > { >- output.write(buffer, 0, readCount); >- progressMonitor.count(readCount); >- if (monitor!=null){ >- if (monitor.isCanceled()) { >- retValue = false; >- break; >- } >- } >+ throw new RemoteFileIOException(new Exception(ftpClient.getReplyString())); > } >- >- progressMonitor.end(); >- >- output.flush(); >- input.close(); >- output.close(); >- >- ftpClient.completePendingCommand(); >- > } >- else >+ finally > { >- throw new RemoteFileIOException(new Exception(ftpClient.getReplyString())); >+ _commandMutex.release(); >+ try { >+ if (input!=null) input.close(); >+ } finally { >+ if (output!=null) output.close(); >+ } > } > } >- catch (FileNotFoundException e) >- { >- throw new RemoteFileIOException(e); >- } >- catch (IOException e) >- { >- throw new RemoteFileIOException(e); >- } >- finally >- { >- _commandMutex.release(); >- } >+ } catch (FileNotFoundException e) { >+ throw new RemoteFileIOException(e); >+ } catch (IOException e) { >+ throw new RemoteFileIOException(e); >+ } finally { >+ progressMonitor.end(); > } >+ > return retValue; > } > >@@ -957,6 +965,7 @@ > _commandMutex.release(); > } > } >+ progressMonitor.end(); > > return hasSucceeded; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 203306
:
78335
|
78377
|
78382