the cleanup process experienced a 100% CPU load situation and the loop

did not terminate:

Occurrences: 100
at java.util.HashMap$KeyIterator.next(HashMap.java:956)
at
net.yacy.cora.protocol.ConnectionInfo.cleanup(ConnectionInfo.java:300)
at
net.yacy.cora.protocol.ConnectionInfo.cleanUp(ConnectionInfo.java:293)
at net.yacy.search.Switchboard.cleanupJob(Switchboard.java:2212)
at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
net.yacy.kelondro.workflow.InstantBusyThread.job(InstantBusyThread.java:105)
at
net.yacy.kelondro.workflow.AbstractBusyThread.run(AbstractBusyThread.java:215)

This tries to fix the problem; the problem should be monitored
pull/1/head
Michael Peter Christen 10 years ago
parent 1f5b5c0111
commit 8ff76f8682

@ -26,12 +26,10 @@
package net.yacy.cora.protocol; package net.yacy.cora.protocol;
import java.util.Collections; import java.util.Collections;
import java.util.ConcurrentModificationException;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set; import java.util.Set;
/** /**
* Information about a connection * Information about a connection
* *
@ -296,12 +294,17 @@ public class ConnectionInfo implements Comparable<ConnectionInfo> {
private static void cleanup(final Set<ConnectionInfo> connectionSet) { private static void cleanup(final Set<ConnectionInfo> connectionSet) {
final Iterator<ConnectionInfo> iter = connectionSet.iterator(); final Iterator<ConnectionInfo> iter = connectionSet.iterator();
synchronized (iter) { synchronized (iter) {
while (iter.hasNext()) try { while (iter.hasNext()) {
ConnectionInfo con = iter.next(); ConnectionInfo con = null;
if(con.getLifetime() > staleAfterMillis) { try {
connectionSet.remove(con); con = iter.next();
} } catch (Throwable e) {break;} // this must break because otherwise there is danger that the loop does never terminates
} catch (ConcurrentModificationException e) {} try {
if (con.getLifetime() > staleAfterMillis) {
connectionSet.remove(con);
}
} catch (Throwable e) {continue;}
}
} }
} }

Loading…
Cancel
Save