From 0d33cf352b05b17e7e4b28c8a30891616819240e Mon Sep 17 00:00:00 2001 From: orbiter Date: Wed, 3 Aug 2011 19:42:18 +0000 Subject: [PATCH] removed synchronization in DNS resolve (solves a problem when loading snippets but in the past concurrent dns requests also caused deadlocks. but this is many years ago and we will give it another try) git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7863 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/net/yacy/cora/protocol/Domains.java | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/source/net/yacy/cora/protocol/Domains.java b/source/net/yacy/cora/protocol/Domains.java index b7b3cb831..797fb6e1b 100644 --- a/source/net/yacy/cora/protocol/Domains.java +++ b/source/net/yacy/cora/protocol/Domains.java @@ -58,7 +58,7 @@ public class Domains { // a dns cache private static final ARC NAME_CACHE_HIT = new ConcurrentARC(MAX_NAME_CACHE_HIT_SIZE, CONCURRENCY_LEVEL); private static final ARC NAME_CACHE_MISS = new ConcurrentARC(MAX_NAME_CACHE_MISS_SIZE, CONCURRENCY_LEVEL); - private static final ConcurrentHashMap LOOKUP_SYNC = new ConcurrentHashMap(); + //private static final ConcurrentHashMap LOOKUP_SYNC = new ConcurrentHashMap(); private static List nameCacheNoCachingPatterns = Collections.synchronizedList(new LinkedList()); private static final List LOCALHOST_PATTERNS = makePatterns(LOCAL_PATTERNS); public static long cacheHit_Hit = 0, cacheHit_Miss = 0, cacheHit_Insert = 0; // for statistics only; do not write @@ -553,26 +553,28 @@ public class Domains { cacheMiss_Miss++; // call dnsResolveNetBased(host) using concurrency to interrupt execution in case of a time-out - final Object sync_obj_new = new Object(); - Object sync_obj = LOOKUP_SYNC.putIfAbsent(host, sync_obj_new); - if (sync_obj == null) sync_obj = sync_obj_new; - synchronized (sync_obj) { + //final Object sync_obj_new = new Object(); + //Object sync_obj = LOOKUP_SYNC.putIfAbsent(host, sync_obj_new); + //if (sync_obj == null) sync_obj = sync_obj_new; + //synchronized (sync_obj) { // now look again if the host is in the cache where it may be meanwhile because of the synchronization + /* ip = NAME_CACHE_HIT.get(host); if (ip != null) { //System.out.println("DNSLOOKUP-CACHE-HIT(SYNC) " + host); - LOOKUP_SYNC.remove(host); + //LOOKUP_SYNC.remove(host); cacheHit_Hit++; return ip; } cacheHit_Miss++; if (NAME_CACHE_MISS.containsKey(host)) { //System.out.println("DNSLOOKUP-CACHE-MISS(SYNC) " + host); - LOOKUP_SYNC.remove(host); + //LOOKUP_SYNC.remove(host); cacheMiss_Hit++; return null; } cacheMiss_Miss++; + */ // do the dns lookup on the dns server //if (!matchesList(host, nameCacheNoCachingPatterns)) System.out.println("DNSLOOKUP " + host); @@ -583,7 +585,7 @@ public class Domains { // add new entries NAME_CACHE_MISS.insertIfAbsent(host, PRESENT); cacheMiss_Insert++; - LOOKUP_SYNC.remove(host); + //LOOKUP_SYNC.remove(host); return null; } @@ -600,9 +602,9 @@ public class Domains { if (globalHosts != null) try {globalHosts.add(host);} catch (final IOException e) {} } } - LOOKUP_SYNC.remove(host); + //LOOKUP_SYNC.remove(host); return ip; - } + //} } private final static Pattern dotPattern = Pattern.compile("\\.");