Refactor: move network COMs out of Network and into Peer in prep for tightening up multicast lookup and other things.

This commit is contained in:
Adam Ierymenko 2015-10-01 11:11:52 -07:00
parent 11ff96ba1d
commit a3db7d0728
11 changed files with 289 additions and 215 deletions

View file

@ -62,7 +62,7 @@ void Topology::setRootServers(const std::map< Identity,std::vector<InetAddress>
if (!p)
p = SharedPtr<Peer>(new Peer(RR->identity,i->first));
for(std::vector<InetAddress>::const_iterator j(i->second.begin());j!=i->second.end();++j)
p->addPath(RemotePath(InetAddress(),*j,true));
p->addPath(RemotePath(InetAddress(),*j,true),now);
p->use(now);
_rootPeers.push_back(p);
}
@ -252,9 +252,12 @@ void Topology::clean(uint64_t now)
Hashtable< Address,SharedPtr<Peer> >::Iterator i(_activePeers);
Address *a = (Address *)0;
SharedPtr<Peer> *p = (SharedPtr<Peer> *)0;
while (i.next(a,p))
while (i.next(a,p)) {
if (((now - (*p)->lastUsed()) >= ZT_PEER_IN_MEMORY_EXPIRATION)&&(std::find(_rootAddresses.begin(),_rootAddresses.end(),*a) == _rootAddresses.end())) {
_activePeers.erase(*a);
} else {
(*p)->clean(RR,now);
}
}
}