Browse Source

Ping supernodes on surface change, and also reset TCP flag.

Adam Ierymenko 10 years ago
parent
commit
eeed31b396
3 changed files with 16 additions and 8 deletions
  1. 0 5
      node/Node.cpp
  2. 12 2
      node/Topology.cpp
  3. 4 1
      node/Topology.hpp

+ 0 - 5
node/Node.cpp

@@ -468,12 +468,7 @@ Node::ReasonForTermination Node::run()
 			}
 			}
 
 
 			if (resynchronize) {
 			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->sm->closeTcpSockets();
-				RR->topology->eachPeer(Topology::ResetActivePeers(RR,now));
 			} else {
 			} else {
 				/* Periodically check for changes in our local multicast subscriptions
 				/* Periodically check for changes in our local multicast subscriptions
 				 * and broadcast those changes to directly connected peers. */
 				 * and broadcast those changes to directly connected peers. */

+ 12 - 2
node/Topology.cpp

@@ -258,7 +258,7 @@ void Topology::clean(uint64_t now)
 	}
 	}
 }
 }
 
 
-bool Topology::updateSurface(const SharedPtr<Peer> &remotePeer,const InetAddress &mirroredAddress)
+bool Topology::updateSurface(const SharedPtr<Peer> &remotePeer,const InetAddress &mirroredAddress,uint64_t now)
 {
 {
 	Mutex::Lock _l(_lock);
 	Mutex::Lock _l(_lock);
 
 
@@ -266,10 +266,20 @@ bool Topology::updateSurface(const SharedPtr<Peer> &remotePeer,const InetAddress
 		return false;
 		return false;
 
 
 	if (_surface.update(mirroredAddress)) {
 	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<Peer> >::const_iterator ap(_activePeers.begin());ap!=_activePeers.end();++ap)
 		for(std::map< Address,SharedPtr<Peer> >::const_iterator ap(_activePeers.begin());ap!=_activePeers.end();++ap)
 			ap->second->clearPaths(false);
 			ap->second->clearPaths(false);
 
 
+		// Reset TCP tunneling if our global addressing has changed
+		if (!mirroredAddress.isLinkLocal())
+			(const_cast <RuntimeEnvironment *>(RR))->tcpTunnelingEnabled = false;
+
+		// Ping supernodes now (other than the one we might have just heard from)
+		for(std::vector< SharedPtr<Peer> >::const_iterator sn(_supernodePeers.begin());sn!=_supernodePeers.end();++sn) {
+			if (remotePeer != *sn)
+				(*sn)->sendPing(RR,now);
+		}
+
 		return true;
 		return true;
 	}
 	}
 
 

+ 4 - 1
node/Topology.hpp

@@ -298,6 +298,7 @@ public:
 	/**
 	/**
 	 * Function object to forget direct links to active peers and then ping them indirectly
 	 * Function object to forget direct links to active peers and then ping them indirectly
 	 */
 	 */
+	/*
 	class ResetActivePeers
 	class ResetActivePeers
 	{
 	{
 	public:
 	public:
@@ -332,6 +333,7 @@ public:
 		std::vector<Address> _supernodeAddresses;
 		std::vector<Address> _supernodeAddresses;
 		const RuntimeEnvironment *RR;
 		const RuntimeEnvironment *RR;
 	};
 	};
+	*/
 
 
 	/**
 	/**
 	 * Function object to collect peers with any known direct path
 	 * Function object to collect peers with any known direct path
@@ -364,8 +366,9 @@ public:
 	 *
 	 *
 	 * @param remotePeer Remote peer address
 	 * @param remotePeer Remote peer address
 	 * @param mirroredAddress Real-world network address the remote peer told us we have
 	 * @param mirroredAddress Real-world network address the remote peer told us we have
+	 * @param now Current time
 	 */
 	 */
-	bool updateSurface(const SharedPtr<Peer> &remotePeer,const InetAddress &mirroredAddress);
+	bool updateSurface(const SharedPtr<Peer> &remotePeer,const InetAddress &mirroredAddress,uint64_t now);
 
 
 	/**
 	/**
 	 * Validate a root topology dictionary against the identities specified in Defaults
 	 * Validate a root topology dictionary against the identities specified in Defaults