Browse Source

Attempt to reactivate dead paths.

Adam Ierymenko 9 years ago
parent
commit
412979ba8f
2 changed files with 10 additions and 2 deletions
  1. 1 1
      node/Peer.hpp
  2. 9 1
      node/Switch.cpp

+ 1 - 1
node/Peer.hpp

@@ -162,7 +162,7 @@ public:
 	 *
 	 *
 	 * @param now Current time
 	 * @param now Current time
 	 * @param inetAddressFamily Keep this address family alive, or 0 to simply pick current best ignoring family
 	 * @param inetAddressFamily Keep this address family alive, or 0 to simply pick current best ignoring family
-	 * @return True if at least one direct path seems alive
+	 * @return True if we have at least one direct path
 	 */
 	 */
 	bool doPingAndKeepalive(uint64_t now,int inetAddressFamily);
 	bool doPingAndKeepalive(uint64_t now,int inetAddressFamily);
 
 

+ 9 - 1
node/Switch.cpp

@@ -754,7 +754,15 @@ bool Switch::_trySend(const Packet &packet,bool encrypt)
 		const uint64_t now = RR->node->now();
 		const uint64_t now = RR->node->now();
 
 
 		SharedPtr<Path> viaPath(peer->getBestPath(now));
 		SharedPtr<Path> viaPath(peer->getBestPath(now));
-		if ( (!viaPath) || ((!viaPath->alive(now))&&(!RR->topology->isRoot(peer->identity()))) ) {
+		if ( (viaPath) && (!viaPath->alive(now)) && (!RR->topology->isRoot(peer->identity())) ) {
+			if ((now - viaPath->lastOut()) > 5000) {
+				Packet outp(peer->address(),RR->identity.address(),Packet::VERB_ECHO);
+				outp.armor(peer->key(),true);
+				viaPath->send(RR,outp.data(),outp.size(),now);
+			}
+			viaPath.zero();
+		}
+		if (!viaPath) {
 			SharedPtr<Peer> relay(RR->topology->getBestRoot());
 			SharedPtr<Peer> relay(RR->topology->getBestRoot());
 			if ( (!relay) || (!(viaPath = relay->getBestPath(now))) )
 			if ( (!relay) || (!(viaPath = relay->getBestPath(now))) )
 				return false;
 				return false;