From eeed31b39639df7e89a2e8ae641d0c3939fa4078 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Mon, 2 Feb 2015 17:02:23 -0800 Subject: [PATCH] Ping supernodes on surface change, and also reset TCP flag. --- node/Node.cpp | 5 ----- node/Topology.cpp | 14 ++++++++++++-- node/Topology.hpp | 5 ++++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/node/Node.cpp b/node/Node.cpp index 8999642bd..9eff2056a 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -468,12 +468,7 @@ Node::ReasonForTermination Node::run() } if (resynchronize) { - /* Send NOP to all peers on resynchronize, directly to supernodes and - * indirectly to regular nodes (to trigger RENDEZVOUS). Also clear - * learned paths since they're likely no longer valid, and close - * TCP sockets since they're also likely invalid. */ RR->sm->closeTcpSockets(); - RR->topology->eachPeer(Topology::ResetActivePeers(RR,now)); } else { /* Periodically check for changes in our local multicast subscriptions * and broadcast those changes to directly connected peers. */ diff --git a/node/Topology.cpp b/node/Topology.cpp index dd0410071..d02991081 100644 --- a/node/Topology.cpp +++ b/node/Topology.cpp @@ -258,7 +258,7 @@ void Topology::clean(uint64_t now) } } -bool Topology::updateSurface(const SharedPtr &remotePeer,const InetAddress &mirroredAddress) +bool Topology::updateSurface(const SharedPtr &remotePeer,const InetAddress &mirroredAddress,uint64_t now) { Mutex::Lock _l(_lock); @@ -266,10 +266,20 @@ bool Topology::updateSurface(const SharedPtr &remotePeer,const InetAddress return false; if (_surface.update(mirroredAddress)) { - // Clear non-fixed paths for all peers + // Clear non-fixed paths for all peers -- will force reconnect on next activity for(std::map< Address,SharedPtr >::const_iterator ap(_activePeers.begin());ap!=_activePeers.end();++ap) ap->second->clearPaths(false); + // Reset TCP tunneling if our global addressing has changed + if (!mirroredAddress.isLinkLocal()) + (const_cast (RR))->tcpTunnelingEnabled = false; + + // Ping supernodes now (other than the one we might have just heard from) + for(std::vector< SharedPtr >::const_iterator sn(_supernodePeers.begin());sn!=_supernodePeers.end();++sn) { + if (remotePeer != *sn) + (*sn)->sendPing(RR,now); + } + return true; } diff --git a/node/Topology.hpp b/node/Topology.hpp index c68bf5076..fcfe2690a 100644 --- a/node/Topology.hpp +++ b/node/Topology.hpp @@ -298,6 +298,7 @@ public: /** * Function object to forget direct links to active peers and then ping them indirectly */ + /* class ResetActivePeers { public: @@ -332,6 +333,7 @@ public: std::vector
_supernodeAddresses; const RuntimeEnvironment *RR; }; + */ /** * Function object to collect peers with any known direct path @@ -364,8 +366,9 @@ public: * * @param remotePeer Remote peer address * @param mirroredAddress Real-world network address the remote peer told us we have + * @param now Current time */ - bool updateSurface(const SharedPtr &remotePeer,const InetAddress &mirroredAddress); + bool updateSurface(const SharedPtr &remotePeer,const InetAddress &mirroredAddress,uint64_t now); /** * Validate a root topology dictionary against the identities specified in Defaults