Skip to content

Commit

Permalink
fix endless loop:
Browse files Browse the repository at this point in the history
Collection does not support remove(int)
(isn't there a smartes way for deleting the first Object?)

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7167 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
sixcooler committed Sep 19, 2010
1 parent 5a9ea03 commit 42fa0ea
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions source/de/anomic/server/serverAccessTracker.java
Expand Up @@ -66,9 +66,11 @@ public serverAccessTracker(long maxTrackingTime, int maxTrackingCount, int maxTr
private synchronized void cleanupAccessTracker() {

if (System.currentTimeMillis() - this.lastCleanup < cleanupCycle) return;
this.lastCleanup = System.currentTimeMillis();

// clear entries which had no entry for the maxTrackingTime time
final Iterator<Map.Entry<String, Collection<Track>>> i = accessTracker.entrySet().iterator();
Iterator<Track> it;
Collection<Track> track;
while (i.hasNext()) {
track = i.next().getValue();
Expand All @@ -77,9 +79,11 @@ private synchronized void cleanupAccessTracker() {
i.remove();
} else {
// check if the maxTrackingCount is exceeded
while (track.size() > this.maxTrackingCount) {
it = track.iterator();
while (track.size() > this.maxTrackingCount && it.hasNext()) {
// delete the oldest entries
track.remove(0);
// track.remove(0);
track.remove(it.next());
}
}
}
Expand All @@ -90,7 +94,7 @@ private synchronized void cleanupAccessTracker() {
accessTracker.remove(accessTracker.keys().nextElement());
}

this.lastCleanup = System.currentTimeMillis();
// this.lastCleanup = System.currentTimeMillis();
}

public static Collection<Track> tailList(Collection<Track> timeList, long time) {
Expand All @@ -110,9 +114,9 @@ private Collection<Track> clearTooOldAccess(final Collection<Track> access) {

public void track(final String host, String accessPath) {
// check storage size
if (System.currentTimeMillis() - this.lastCleanup > cleanupCycle) {
// if (System.currentTimeMillis() - this.lastCleanup > cleanupCycle) {
cleanupAccessTracker();
}
// }

// learn that a specific host has accessed a specific path
if (accessPath == null) accessPath="NULL";
Expand All @@ -130,7 +134,7 @@ public Collection<Track> accessTrack(final String host) {
if (access == null) return null;
// clear too old entries
synchronized (access) {
if ((access = clearTooOldAccess(access)).size() != access.size()) {
if (access.size() != (access = clearTooOldAccess(access)).size()) {
// write back to tracker
if (access.isEmpty()) {
accessTracker.remove(host);
Expand Down

0 comments on commit 42fa0ea

Please sign in to comment.