From 586bc4d920b7371a4ef617d6465ad1053de9761f Mon Sep 17 00:00:00 2001 From: orbiter Date: Tue, 11 May 2010 22:26:18 +0000 Subject: [PATCH] - 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 --- htroot/yacy/search.java | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/htroot/yacy/search.java b/htroot/yacy/search.java index 841b2a95b..14a99ede5 100644 --- a/htroot/yacy/search.java +++ b/htroot/yacy/search.java @@ -146,14 +146,16 @@ public final class search { TreeSet trackerHandles = sb.remoteSearchTracker.get(client); if (trackerHandles == null) trackerHandles = new TreeSet(); boolean block = false; - if (trackerHandles.tailSet(Long.valueOf(System.currentTimeMillis() - 3000)).size() > 1) { - block = true; - } - if (trackerHandles.tailSet(Long.valueOf(System.currentTimeMillis() - 60000)).size() > 12) { - block = true; - } - if (trackerHandles.tailSet(Long.valueOf(System.currentTimeMillis() - 600000)).size() > 36) { - block = true; + synchronized (trackerHandles) { + if (trackerHandles.tailSet(Long.valueOf(System.currentTimeMillis() - 3000)).size() > 1) { + block = true; + } + if (trackerHandles.tailSet(Long.valueOf(System.currentTimeMillis() - 60000)).size() > 12) { + block = true; + } + if (trackerHandles.tailSet(Long.valueOf(System.currentTimeMillis() - 600000)).size() > 36) { + block = true; + } } if (block) { prop.put("links", ""); @@ -386,10 +388,13 @@ public final class search { sb.remoteSearches.add(theQuery); // 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); - // log yacyCore.log.logInfo("EXIT HASH SEARCH: " + QueryParams.anonymizedQueryHashes(theQuery.queryHashes) + " - " + joincount + " links found, " +