diff options
author | Eugene Tarassov | 2012-08-15 22:59:29 +0000 |
---|---|---|
committer | Eugene Tarassov | 2012-08-15 22:59:29 +0000 |
commit | 77fc313c30a8754d5711629b5e2615e32a084a85 (patch) | |
tree | 64c208981ce4c66d533c7d6b2f41007ed5b140a1 /plugins/org.eclipse.tcf.core | |
parent | 31329d3fcb5a7bdf886bee8d0b61aca3bc071257 (diff) | |
download | org.eclipse.tcf-77fc313c30a8754d5711629b5e2615e32a084a85.tar.gz org.eclipse.tcf-77fc313c30a8754d5711629b5e2615e32a084a85.tar.xz org.eclipse.tcf-77fc313c30a8754d5711629b5e2615e32a084a85.zip |
TCF Core: better handling of network configuration changes in TCF discovery
Diffstat (limited to 'plugins/org.eclipse.tcf.core')
-rw-r--r-- | plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/internal/services/local/LocatorService.java | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/internal/services/local/LocatorService.java b/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/internal/services/local/LocatorService.java index 60203b199..d3ed286e7 100644 --- a/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/internal/services/local/LocatorService.java +++ b/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/internal/services/local/LocatorService.java @@ -179,13 +179,13 @@ public class LocatorService implements ILocator { public void run() { while (true) { try { - sleep(DATA_RETENTION_PERIOD / 4); final HashSet<SubNet> set = getSubNetList(); Protocol.invokeAndWait(new Runnable() { public void run() { refresh_timer(set); } }); + sleep(DATA_RETENTION_PERIOD / 4); } catch (IllegalStateException x) { // TCF event dispatch is shut down @@ -364,7 +364,6 @@ public class LocatorService implements ILocator { LoggingUtil.trace("Became a slave agent (bound to port " + socket.getLocalPort() + ")"); } } - refreshSubNetList(getSubNetList()); input_thread.setName("TCF Locator Receiver"); timer_thread.setName("TCF Locator Timer"); dns_lookup_thread.setName("TCF Locator DNS Lookup"); @@ -390,8 +389,6 @@ public class LocatorService implements ILocator { public void peerRemoved(String id) { } }); - sendPeersRequest(null, 0); - sendAll(null, 0, null, System.currentTimeMillis()); } catch (Exception x) { log("Cannot open UDP socket for TCF discovery protocol", x); @@ -528,7 +525,7 @@ public class LocatorService implements ILocator { catch (Throwable x) { } } - refreshSubNetList(nets); + if (refreshSubNetList(nets)) sendPeersRequest(null, 0); if (socket.getLocalPort() != DISCOVERY_PORT) { for (SubNet subnet : subnets) { addSlave(subnet.address, socket.getLocalPort(), time); @@ -558,17 +555,19 @@ public class LocatorService implements ILocator { return s; } - private void refreshSubNetList(HashSet<SubNet> set) { - if (set == null) return; + private boolean refreshSubNetList(HashSet<SubNet> set) { + if (set == null) return false; for (Iterator<SubNet> i = subnets.iterator(); i.hasNext();) { SubNet s = i.next(); if (set.contains(s)) continue; i.remove(); } + boolean new_nets = false; for (Iterator<SubNet> i = set.iterator(); i.hasNext();) { SubNet s = i.next(); if (subnets.contains(s)) continue; subnets.add(s); + new_nets = true; } if (TRACE_DISCOVERY) { StringBuilder str = new StringBuilder("Refreshed subnet list:"); @@ -577,6 +576,7 @@ public class LocatorService implements ILocator { } LoggingUtil.trace(str.toString()); } + return new_nets; } private HashSet<SubNet> getSubNetList() { |