Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

protection against too long running snippet fetch processes

Michael Christen3eccdca63c25
diff --git a/source/de/anomic/http/client/Cache.java b/source/de/anomic/http/client/Cache.java
index ca84c9aba..8eba2c6c1 100644
--- a/source/de/anomic/http/client/Cache.java
+++ b/source/de/anomic/http/client/Cache.java
@@ -86,7 +86,7 @@ public final class Cache {
try {
fileDBunbuffered = new ArrayStack(new File(cachePath, FILE_DB_NAME), prefix, Base64Order.enhancedCoder, 12, 1024 * 1024 * 2, false);
fileDBunbuffered.setMaxSize(maxCacheSize);
- fileDB = new Compressor(fileDBunbuffered, 2 * 1024 * 1024);
+ fileDB = new Compressor(fileDBunbuffered, 6 * 1024 * 1024);
} catch (final IOException e) {
Log.logException(e);
}
diff --git a/source/net/yacy/search/query/SnippetProcess.java b/source/net/yacy/search/query/SnippetProcess.java
index 00ddfe4d3..b2eb85473 100644
--- a/source/net/yacy/search/query/SnippetProcess.java
+++ b/source/net/yacy/search/query/SnippetProcess.java
@@ -189,6 +189,7 @@ public class SnippetProcess {
}
final ResultEntry re = entry.getElement();
EventTracker.update(EventTracker.EClass.SEARCH, new ProfilingGraph.EventSearch(this.query.id(true), SearchEvent.Type.ONERESULT, "retrieved, item = " + item + ", available = " + this.result.sizeAvailable() + ": " + re.urlstring(), 0, 0), false);
+ if (item == this.query.offset + this.query.itemsPerPage - 1) stopAllWorker(); // we don't need more
return re;
}
@@ -337,6 +338,16 @@ public class SnippetProcess {
}
}
}
+
+ public void stopAllWorker() {
+ synchronized(this.workerThreads) {
+ for (int i = 0; i < this.workerThreads.length; i++) {
+ if (this.workerThreads[i] == null || !this.workerThreads[i].isAlive()) continue;
+ this.workerThreads[i].pleaseStop();
+ this.workerThreads[i].interrupt();
+ }
+ }
+ }
private boolean anyWorkerAlive() {
if (this.workerThreads == null || this.workerThreads.length == 0) return false;