1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-03 15:15:25 +02:00

[380562] [multithread][dstore] File Search is not canceled by the client UI on disconnect

This commit is contained in:
David McKnight 2012-05-24 20:10:06 +00:00
parent 907609f52b
commit 0a07aa4dc8
2 changed files with 24 additions and 2 deletions

View file

@ -43,6 +43,7 @@
* David McKnight (IBM) - [283617] [dstore] UniversalFileSystemMiner.handleQueryGetRemoteObject does not return correct result when the queried file does not exist.
* David McKnight (IBM) - [dstore] cancelable threads not removed fast enough from Hashmap, resulting in OOM
* David McKnight (IBM) - [371401] [dstore][multithread] avoid use of static variables - causes memory leak after disconnect
* Noriaki Takatsu (IBM) - [380562] [multithread][dstore] File Search is not canceled by the client UI on disconnect
*******************************************************************************/
package org.eclipse.rse.dstore.universal.miners;
@ -54,6 +55,7 @@ import java.net.ServerSocket;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import org.eclipse.dstore.core.miners.Miner;
@ -1362,7 +1364,26 @@ public class UniversalFileSystemMiner extends Miner {
}
public void finish() {
_cancellableThreads.clear();
try {
if (_cancellableThreads != null) {
Set keys = _cancellableThreads.keySet();
Iterator iteratorKeys = keys.iterator();
while (iteratorKeys.hasNext()) {
Object key = iteratorKeys.next();
ICancellableHandler thread = (ICancellableHandler) _cancellableThreads.get(key);
if (thread != null) {
if (!thread.isDone()) {
thread.cancel();
}
}
}
_cancellableThreads.clear();
}
}
catch(Throwable e) {
e.printStackTrace();
}
super.finish();
}

View file

@ -29,6 +29,7 @@
* David McKnight (IBM) - [358301] [DSTORE] Hang during debug source look up
* Noriaki Takatsu (IBM) - [362025] [dstore] Search for text hung in encountering a device definition
* David McKnight (IBM) - [371401] [dstore][multithread] avoid use of static variables - causes memory leak after disconnect
* Noriaki Takatsu (IBM) - [380562] [multithread][dstore] File Search is not canceled by the client UI on disconnect
********************************************************************************/
package org.eclipse.rse.internal.dstore.universal.miners.filesystem;
@ -406,7 +407,7 @@ public class UniversalSearchHandler extends SecuredThread implements ICancellabl
long MAX_READ = MAX_FILE / 10; // read no more than a tenth of max file at a time
int offset = 0;
while (offset < fileLength && !matched){
while (offset < fileLength && !matched && !_isCancelled){
long readSize = MAX_READ;
if (offset + MAX_READ > fileLength){
readSize = fileLength - offset;