mirror of
https://github.com/yacy/yacy_search_server.git
synced 2026-10-25 05:54:15 +00:00
fix for ConnectionInfo.cleanup of server-connections
This commit is contained in:
1 parent
6f707b4305
commit
eb9d2705d2
1 file changed
+5
-4
@@ -289,16 +289,17 @@ public class ConnectionInfo implements Comparable<ConnectionInfo> {
|
||||
* removes stale connections
|
||||
*/
|
||||
public static void cleanUp() {
|
||||
cleanup(getAllConnections().iterator());
|
||||
cleanup(getServerConnections().iterator());
|
||||
cleanup(getAllConnections());
|
||||
cleanup(getServerConnections());
|
||||
}
|
||||
|
||||
private static void cleanup(final Iterator<ConnectionInfo> iter) {
|
||||
private static void cleanup(final Set<ConnectionInfo> connectionSet) {
|
||||
final Iterator<ConnectionInfo> iter = connectionSet.iterator();
|
||||
synchronized (iter) {
|
||||
while (iter.hasNext()) try {
|
||||
ConnectionInfo con = iter.next();
|
||||
if(con.getLifetime() > staleAfterMillis) {
|
||||
getAllConnections().remove(con);
|
||||
connectionSet.remove(con);
|
||||
}
|
||||
} catch (ConcurrentModificationException e) {}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user