summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-05-04 19:02:36 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-05-04 19:02:36 -0700
commit40f312a827ffecf7d5a233ee5d13b0a3bc88e8a6 (patch)
treec70f4b3e0a286667b00546da97b445b8a1d01dff
parent18ca6f34ff91a79fd67050459ec68c65ab3ff851 (diff)
downloadinfinitytier-40f312a827ffecf7d5a233ee5d13b0a3bc88e8a6.tar.gz
infinitytier-40f312a827ffecf7d5a233ee5d13b0a3bc88e8a6.zip
When we reset within scope, erase the other entries for that scope so we won't keep resetting the same scope repeatedly.
-rw-r--r--node/SelfAwareness.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/node/SelfAwareness.cpp b/node/SelfAwareness.cpp
index 425fbb0b..d7c0e5cc 100644
--- a/node/SelfAwareness.cpp
+++ b/node/SelfAwareness.cpp
@@ -105,6 +105,14 @@ void SelfAwareness::iam(const Address &reporter,const InetAddress &reporterPhysi
entry.ts = now;
TRACE("learned physical address %s for scope %u as seen from %s(%s) (replaced %s, resetting all in scope)",myPhysicalAddress.toString().c_str(),(unsigned int)scope,reporter.toString().c_str(),reporterPhysicalAddress.toString().c_str(),entry.mySurface.toString().c_str());
+ // Erase all entries (other than this one) for this scope to prevent thrashing
+ // Note: we should probably not use 'entry' after this
+ for(std::map< PhySurfaceKey,PhySurfaceEntry >::iterator p(_phy.begin());p!=_phy.end();) {
+ if ((p->first.reporter != reporter)&&(p->first.scope == scope))
+ _phy.erase(p++);
+ else ++p;
+ }
+
_ResetWithinScope rset(RR,now,(InetAddress::IpScope)scope);
RR->topology->eachPeer<_ResetWithinScope &>(rset);
@@ -124,7 +132,9 @@ void SelfAwareness::iam(const Address &reporter,const InetAddress &reporterPhysi
}
}
}
- } else entry.ts = now;
+ } else {
+ entry.ts = now;
+ }
}
void SelfAwareness::clean(uint64_t now)