- remove superfluous entries in remote search tracker handles

- avoid concurrent access from same client
this is a fix for http://forum.yacy-websuche.de/viewtopic.php?p=20045#p20045

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6866 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 15 years ago
parent 789c6b26ce
commit 586bc4d920

@ -146,6 +146,7 @@ public final class search {
TreeSet<Long> trackerHandles = sb.remoteSearchTracker.get(client); TreeSet<Long> trackerHandles = sb.remoteSearchTracker.get(client);
if (trackerHandles == null) trackerHandles = new TreeSet<Long>(); if (trackerHandles == null) trackerHandles = new TreeSet<Long>();
boolean block = false; boolean block = false;
synchronized (trackerHandles) {
if (trackerHandles.tailSet(Long.valueOf(System.currentTimeMillis() - 3000)).size() > 1) { if (trackerHandles.tailSet(Long.valueOf(System.currentTimeMillis() - 3000)).size() > 1) {
block = true; block = true;
} }
@ -155,6 +156,7 @@ public final class search {
if (trackerHandles.tailSet(Long.valueOf(System.currentTimeMillis() - 600000)).size() > 36) { if (trackerHandles.tailSet(Long.valueOf(System.currentTimeMillis() - 600000)).size() > 36) {
block = true; block = true;
} }
}
if (block) { if (block) {
prop.put("links", ""); prop.put("links", "");
prop.put("linkcount", "0"); prop.put("linkcount", "0");
@ -386,10 +388,13 @@ public final class search {
sb.remoteSearches.add(theQuery); sb.remoteSearches.add(theQuery);
// update the search tracker // update the search tracker
trackerHandles.add(theQuery.handle); synchronized (trackerHandles) {
trackerHandles.add(theQuery.handle); // thats the time when the handle was created
// we don't need too much entries in the list; remove superfluous
while (trackerHandles.size() > 36) if (!trackerHandles.remove(trackerHandles.first())) break;
}
sb.remoteSearchTracker.put(client, trackerHandles); sb.remoteSearchTracker.put(client, trackerHandles);
// log // log
yacyCore.log.logInfo("EXIT HASH SEARCH: " + yacyCore.log.logInfo("EXIT HASH SEARCH: " +
QueryParams.anonymizedQueryHashes(theQuery.queryHashes) + " - " + joincount + " links found, " + QueryParams.anonymizedQueryHashes(theQuery.queryHashes) + " - " + joincount + " links found, " +

Loading…
Cancel
Save