Переглянути джерело

When we reset within scope, erase the other entries for that scope so we won't keep resetting the same scope repeatedly.

Adam Ierymenko 10 роки тому
батько
коміт
40f312a827
1 змінених файлів з 11 додано та 1 видалено
  1. 11 1
      node/SelfAwareness.cpp

+ 11 - 1
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)