Clean up WHOIS code.
This commit is contained in:
parent
b1d94c9f93
commit
6ee201865b
12 changed files with 115 additions and 144 deletions
|
@ -249,6 +249,19 @@ ZT_ResultCode Node::processBackgroundTasks(void *tptr,uint64_t now,volatile uint
|
|||
try {
|
||||
_lastPingCheck = now;
|
||||
|
||||
// Do pings and keepalives
|
||||
Hashtable< Address,std::vector<InetAddress> > upstreamsToContact;
|
||||
RR->topology->getUpstreamsToContact(upstreamsToContact);
|
||||
_PingPeersThatNeedPing pfunc(RR,tptr,upstreamsToContact,now);
|
||||
RR->topology->eachPeer<_PingPeersThatNeedPing &>(pfunc);
|
||||
|
||||
// Run WHOIS to create Peer for any upstreams we could not contact (including pending moon seeds)
|
||||
Hashtable< Address,std::vector<InetAddress> >::Iterator i(upstreamsToContact);
|
||||
Address *upstreamAddress = (Address *)0;
|
||||
std::vector<InetAddress> *upstreamStableEndpoints = (std::vector<InetAddress> *)0;
|
||||
while (i.next(upstreamAddress,upstreamStableEndpoints))
|
||||
RR->sw->requestWhois(tptr,now,*upstreamAddress);
|
||||
|
||||
// Get networks that need config without leaving mutex locked
|
||||
{
|
||||
std::vector< std::pair< SharedPtr<Network>,bool > > nwl;
|
||||
|
@ -268,19 +281,6 @@ ZT_ResultCode Node::processBackgroundTasks(void *tptr,uint64_t now,volatile uint
|
|||
}
|
||||
}
|
||||
|
||||
// Do pings and keepalives
|
||||
Hashtable< Address,std::vector<InetAddress> > upstreamsToContact;
|
||||
RR->topology->getUpstreamsToContact(upstreamsToContact);
|
||||
_PingPeersThatNeedPing pfunc(RR,tptr,upstreamsToContact,now);
|
||||
RR->topology->eachPeer<_PingPeersThatNeedPing &>(pfunc);
|
||||
|
||||
// Run WHOIS to create Peer for any upstreams we could not contact (including pending moon seeds)
|
||||
Hashtable< Address,std::vector<InetAddress> >::Iterator i(upstreamsToContact);
|
||||
Address *upstreamAddress = (Address *)0;
|
||||
std::vector<InetAddress> *upstreamStableEndpoints = (std::vector<InetAddress> *)0;
|
||||
while (i.next(upstreamAddress,upstreamStableEndpoints))
|
||||
RR->sw->requestWhois(tptr,*upstreamAddress);
|
||||
|
||||
// Update online status, post status change as event
|
||||
const bool oldOnline = _online;
|
||||
_online = (((now - pfunc.lastReceiveFromUpstream) < ZT_PEER_ACTIVITY_TIMEOUT)||(RR->topology->amRoot()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue