From 80c77965aa83e52bd16f70d8605d8ebe4ff3c11e Mon Sep 17 00:00:00 2001 From: Ingo Bauersachs Date: Tue, 22 Nov 2011 21:00:34 +0000 Subject: Reset DNS server list after network change also when the ParallelResolver is disabled --- .../java/sip/communicator/util/NetworkUtils.java | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'src/net/java/sip/communicator/util') diff --git a/src/net/java/sip/communicator/util/NetworkUtils.java b/src/net/java/sip/communicator/util/NetworkUtils.java index 76fd6c2..0a2badb 100644 --- a/src/net/java/sip/communicator/util/NetworkUtils.java +++ b/src/net/java/sip/communicator/util/NetworkUtils.java @@ -9,6 +9,7 @@ package net.java.sip.communicator.util; import java.beans.*; import java.net.*; import java.util.*; +import java.util.concurrent.atomic.*; import net.java.sip.communicator.service.netaddr.event.*; import net.java.sip.communicator.util.dns.*; @@ -133,6 +134,16 @@ public class NetworkUtils private final static Object parallelResolverLock = new Object(); /** + * Initialization flag for {@link #netListener} + */ + private static final AtomicBoolean netListenerAdded = new AtomicBoolean(); + + /** + * Listener for network change events to reset the DNS resolvers. + */ + private static final NetworkListener netListener = new NetworkListener(); + + /** * Determines whether the address is the result of windows auto configuration. * (i.e. One that is in the 169.254.0.0 network) * @param add the address to inspect @@ -1140,6 +1151,12 @@ public class NetworkUtils private static Lookup createLookup(String domain, int type) throws TextParseException { + // listens for network changes up/down so we can reset + // dns configuration + if(netListenerAdded.compareAndSet(false, true)) + UtilActivator.getNetworkAddressManagerService() + .addNetworkConfigurationChangeListener(netListener); + Lookup lookup = new Lookup(domain, type); if(!UtilActivator.getConfigurationService() @@ -1197,12 +1214,6 @@ public class NetworkUtils parallelResolver = new ParallelResolver( new InetSocketAddress[]{resolverSockAddr}); - // listens for network changes up/down so we can reset - // dns configuration - UtilActivator.getNetworkAddressManagerService() - .addNetworkConfigurationChangeListener( - new NetworkListener()); - //listens for changes on the parallel DNS settings UtilActivator.getConfigurationService() .addPropertyChangeListener( -- cgit v1.1