mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
fix for 100% cpu bug during dht selection
see also: http://www.yacy-forum.de/viewtopic.php?p=34068#34068 git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3570 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
parent
f15fa7c5b1
commit
063063aa0c
|
@ -47,6 +47,9 @@ public class kelondroRotateIterator implements kelondroCloneableIterator {
|
|||
}
|
||||
|
||||
public Object next() {
|
||||
// attention: this iterator has no termination - on purpose.
|
||||
// it must be taken care that a calling method has a termination predicate different
|
||||
// from the hasNext() method
|
||||
if (!(a.hasNext())) {
|
||||
a = (kelondroCloneableIterator) clone.clone(modifier);
|
||||
}
|
||||
|
|
|
@ -496,14 +496,18 @@ public final class plasmaWordIndex implements indexRI {
|
|||
Iterator i = wordContainers(startHash, ram, rot);
|
||||
if (ram) count = Math.min(dhtOutCache.size(), count);
|
||||
indexContainer container;
|
||||
// this loop does not terminate using the i.hasNex() predicate when rot == true
|
||||
// because then the underlying iterator is a rotating iterator without termination
|
||||
// in this case a termination must be ensured with a counter
|
||||
// It must also be ensured that the counter is in/decreased every loop
|
||||
while ((count > 0) && (i.hasNext())) {
|
||||
container = (indexContainer) i.next();
|
||||
if ((container != null) && (container.size() > 0)) {
|
||||
containers.add(container);
|
||||
count--;
|
||||
}
|
||||
count--; // decrease counter even if the container was null or empty to ensure termination
|
||||
}
|
||||
return containers;
|
||||
return containers; // this may return less containers as demanded
|
||||
}
|
||||
|
||||
public kelondroCloneableIterator wordContainers(String startHash, boolean ram, boolean rot) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user