summaryrefslogtreecommitdiff
path: root/node/Node.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2017-01-27 16:16:06 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2017-01-27 16:16:06 -0800
commit9e7c778cc8ebdfd5d3f773a7d3cb30ad154e7189 (patch)
tree4529d35d2d4d6aad2374cb4b210de84eccb07eef /node/Node.cpp
parent1d775af34a5efa6008256d1bfa742c28ee7152ab (diff)
downloadinfinitytier-9e7c778cc8ebdfd5d3f773a7d3cb30ad154e7189.tar.gz
infinitytier-9e7c778cc8ebdfd5d3f773a7d3cb30ad154e7189.zip
Fix deadlock.
Diffstat (limited to 'node/Node.cpp')
-rw-r--r--node/Node.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/node/Node.cpp b/node/Node.cpp
index c4a40395..3d5b5c3d 100644
--- a/node/Node.cpp
+++ b/node/Node.cpp
@@ -159,7 +159,8 @@ public:
_PingPeersThatNeedPing(const RuntimeEnvironment *renv,uint64_t now) :
lastReceiveFromUpstream(0),
RR(renv),
- _now(now)
+ _now(now),
+ _bestCurrentUpstream(RR->topology->getUpstreamPeer())
{
RR->topology->getUpstreamStableEndpoints(_upstreams);
}
@@ -194,8 +195,11 @@ public:
}
} else contacted = true;
- if (!contacted)
- p->sendHELLO(InetAddress(),InetAddress(),_now);
+ if ((!contacted)&&(_bestCurrentUpstream)) {
+ const SharedPtr<Path> up(_bestCurrentUpstream->getBestPath(_now,true));
+ if (up)
+ p->sendHELLO(up->localAddress(),up->address(),_now);
+ }
lastReceiveFromUpstream = std::max(p->lastReceive(),lastReceiveFromUpstream);
} else if (p->isActive(_now)) {
@@ -205,7 +209,8 @@ public:
private:
const RuntimeEnvironment *RR;
- uint64_t _now;
+ const uint64_t _now;
+ const SharedPtr<Peer> _bestCurrentUpstream;
Hashtable< Address,std::vector<InetAddress> > _upstreams;
};