diff --git a/source/de/anomic/http/httpd.java b/source/de/anomic/http/httpd.java index e56d7ac3d..3505141f1 100644 --- a/source/de/anomic/http/httpd.java +++ b/source/de/anomic/http/httpd.java @@ -733,7 +733,7 @@ public final class httpd implements serverHandler { // reseting the empty request counter this.emptyRequestCount = 0; - // counting the amount of received requests within this permanent conneciton + // counting the amount of received requests within this permanent connection this.prop.setProperty(httpHeader.CONNECTION_PROP_KEEP_ALIVE_COUNT, Integer.toString(++this.keepAliveRequestCount)); // setting the client-IP diff --git a/source/de/anomic/server/serverAbstractSwitch.java b/source/de/anomic/server/serverAbstractSwitch.java index a7eb88824..4146c4632 100644 --- a/source/de/anomic/server/serverAbstractSwitch.java +++ b/source/de/anomic/server/serverAbstractSwitch.java @@ -43,11 +43,11 @@ package de.anomic.server; import java.io.File; import java.io.IOException; import java.net.InetAddress; -import java.util.ConcurrentModificationException; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.TreeMap; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.LinkedBlockingQueue; import de.anomic.server.logging.serverLog; @@ -68,7 +68,7 @@ public abstract class serverAbstractSwitch implements serverSwitch { private HashMap authorization; private TreeMap workerThreads; private TreeMap switchActions; - protected HashMap> accessTracker; // mappings from requesting host to an ArrayList of serverTrack-entries + protected ConcurrentHashMap> accessTracker; // mappings from requesting host to an ArrayList of serverTrack-entries private LinkedBlockingQueue cacheStack; public serverAbstractSwitch(File rootPath, String initPath, String configPath, boolean applyPro) { @@ -148,7 +148,7 @@ public abstract class serverAbstractSwitch implements serverSwitch { // other settings authorization = new HashMap(); - accessTracker = new HashMap>(); + accessTracker = new ConcurrentHashMap>(); // init thread control workerThreads = new TreeMap(); @@ -177,14 +177,10 @@ public abstract class serverAbstractSwitch implements serverSwitch { if (accessPath == null) accessPath="NULL"; TreeMap access = accessTracker.get(host); if (access == null) access = new TreeMap(); - synchronized (access) { - access.put(new Long(System.currentTimeMillis()), accessPath); + access.put(new Long(System.currentTimeMillis()), accessPath); - // write back to tracker - try { - accessTracker.put(host, clearTooOldAccess(access)); - } catch (ConcurrentModificationException e) {}; - } + // write back to tracker + accessTracker.put(host, clearTooOldAccess(access)); } public TreeMap accessTrack(String host) { @@ -192,20 +188,17 @@ public abstract class serverAbstractSwitch implements serverSwitch { TreeMap access = accessTracker.get(host); if (access == null) return null; - synchronized (access) { - // clear too old entries - int oldsize = access.size(); - if ((access = clearTooOldAccess(access)).size() != oldsize) { - // write back to tracker - if (access.size() == 0) { - accessTracker.remove(host); - } else { - accessTracker.put(host, access); - } + // clear too old entries + if ((access = clearTooOldAccess(access)).size() != access.size()) { + // write back to tracker + if (access.size() == 0) { + accessTracker.remove(host); + } else { + accessTracker.put(host, access); } - - return access; } + + return access; } private TreeMap clearTooOldAccess(TreeMap access) { @@ -215,9 +208,7 @@ public abstract class serverAbstractSwitch implements serverSwitch { public Iterator accessHosts() { // returns an iterator of hosts in tracker (String) HashMap> accessTrackerClone = new HashMap>(); - try { - accessTrackerClone.putAll(accessTracker); - } catch (ConcurrentModificationException e) {} + accessTrackerClone.putAll(accessTracker); return accessTrackerClone.keySet().iterator(); }