summaryrefslogtreecommitdiff
path: root/node/Topology.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2016-09-02 12:34:02 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2016-09-02 12:34:02 -0700
commit4931e449989f74b9518d15bc69521fdbefb313e7 (patch)
treeae97532c0318b76bcc708f711a145c62bdd96323 /node/Topology.cpp
parentd1101441b3d43ee69c1b661cc5f777a09fd10fca (diff)
downloadinfinitytier-4931e449989f74b9518d15bc69521fdbefb313e7.tar.gz
infinitytier-4931e449989f74b9518d15bc69521fdbefb313e7.zip
Implement "weak pointer" behavior on Topology Path canonicalization hash table.
Diffstat (limited to 'node/Topology.cpp')
-rw-r--r--node/Topology.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/node/Topology.cpp b/node/Topology.cpp
index 6e0fe90c..c6d46dc5 100644
--- a/node/Topology.cpp
+++ b/node/Topology.cpp
@@ -251,14 +251,25 @@ bool Topology::worldUpdateIfValid(const World &newWorld)
void Topology::clean(uint64_t now)
{
Mutex::Lock _l(_lock);
- Hashtable< Address,SharedPtr<Peer> >::Iterator i(_peers);
- Address *a = (Address *)0;
- SharedPtr<Peer> *p = (SharedPtr<Peer> *)0;
- while (i.next(a,p)) {
- if (((now - (*p)->lastUsed()) >= ZT_PEER_IN_MEMORY_EXPIRATION)&&(std::find(_rootAddresses.begin(),_rootAddresses.end(),*a) == _rootAddresses.end())) {
- _peers.erase(*a);
- } else {
- (*p)->clean(now);
+ {
+ Hashtable< Address,SharedPtr<Peer> >::Iterator i(_peers);
+ Address *a = (Address *)0;
+ SharedPtr<Peer> *p = (SharedPtr<Peer> *)0;
+ while (i.next(a,p)) {
+ if (((now - (*p)->lastUsed()) >= ZT_PEER_IN_MEMORY_EXPIRATION)&&(std::find(_rootAddresses.begin(),_rootAddresses.end(),*a) == _rootAddresses.end())) {
+ _peers.erase(*a);
+ } else {
+ (*p)->clean(now);
+ }
+ }
+ }
+ {
+ Hashtable< Path::HashKey,SharedPtr<Path> >::Iterator i(_paths);
+ Path::HashKey *k = (Path::HashKey *)0;
+ SharedPtr<Path> *p = (SharedPtr<Path> *)0;
+ while (i.next(k,p)) {
+ if (p->reclaimIfWeak())
+ _paths.erase(*k);
}
}
}