From 40bfe37a1904b93d1ab3c6e5c83ea927b64002a6 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Wed, 8 Apr 2015 14:58:23 -0700 Subject: [PATCH] Use max of core or most recent path desperation for pings. --- node/Peer.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/node/Peer.cpp b/node/Peer.cpp index e66722e8a..3270a2311 100644 --- a/node/Peer.cpp +++ b/node/Peer.cpp @@ -191,14 +191,15 @@ void Peer::doPingAndKeepalive(const RuntimeEnvironment *RR,uint64_t now) { Path *const bestPath = getBestPath(now); if ((bestPath)&&(bestPath->active(now))) { + const unsigned int desp = std::max(RR->node->coreDesperation(),bestPath->lastReceiveDesperation()); if ((now - bestPath->lastReceived()) >= ZT_PEER_DIRECT_PING_DELAY) { - attemptToContactAt(RR,bestPath->address(),bestPath->desperation(now),now); + attemptToContactAt(RR,bestPath->address(),desp,now); bestPath->sent(now); } else if ((now - bestPath->lastSend()) >= ZT_NAT_KEEPALIVE_DELAY) { // We only do keepalive if desperation is zero right now, since higher // desperation paths involve things like tunneling that do not need it. - if (bestPath->desperation() == 0) { - RR->node->putPacket(_paths[p].address(),"",0,0); + if (desp == 0) { + RR->node->putPacket(bestPath->address(),"",0,0); bestPath->sent(now); } } @@ -261,7 +262,7 @@ void Peer::resetWithinScope(const RuntimeEnvironment *RR,InetAddress::IpScope sc while (x < np) { if (_paths[x].address().ipScope() == scope) { if (_paths[x].fixed()) { - attemptToContactAt(RR,_paths[x].address(),_paths[x].desperation(now),now); + attemptToContactAt(RR,_paths[x].address(),_paths[x].lastReceiveDesperation(),now); _paths[y++] = _paths[x]; // keep fixed paths } } else {