diff --git a/core/src/main/groovy/com/muwire/core/hostcache/Host.groovy b/core/src/main/groovy/com/muwire/core/hostcache/Host.groovy index 351314e6..d283f745 100644 --- a/core/src/main/groovy/com/muwire/core/hostcache/Host.groovy +++ b/core/src/main/groovy/com/muwire/core/hostcache/Host.groovy @@ -30,4 +30,8 @@ class Host { synchronized boolean hasSucceeded() { successes > 0 } + + synchronized void clearFailures() { + failures = null + } } diff --git a/core/src/main/groovy/com/muwire/core/hostcache/HostCache.groovy b/core/src/main/groovy/com/muwire/core/hostcache/HostCache.groovy index 3f02710e..1594e806 100644 --- a/core/src/main/groovy/com/muwire/core/hostcache/HostCache.groovy +++ b/core/src/main/groovy/com/muwire/core/hostcache/HostCache.groovy @@ -46,8 +46,12 @@ class HostCache extends Service { void onHostDiscoveredEvent(HostDiscoveredEvent e) { if (myself == e.destination) return - if (hosts.containsKey(e.destination) && !e.fromHostcache) + if (hosts.containsKey(e.destination)) { + if (!e.fromHostcache) return + hosts.get(e.destination).clearFailures() + return + } Host host = new Host(e.destination) if (allowHost(host)) { hosts.put(e.destination, host)