Fix purgeOutdatedHistory
This commit is contained in:
parent
4dffb61f78
commit
d32d18ea64
|
@ -29,12 +29,12 @@ void HealthMonitor::reportPeerClosed(const NetworkAddress& peerAddress) {
|
|||
}
|
||||
|
||||
void HealthMonitor::purgeOutdatedHistory() {
|
||||
for (auto it = peerClosedHistory.begin(); it != peerClosedHistory.end();) {
|
||||
if (it->first < now() - FLOW_KNOBS->HEALTH_MONITOR_CLIENT_REQUEST_INTERVAL_SECS) {
|
||||
auto& count = peerClosedNum[it->second];
|
||||
while (!peerClosedHistory.empty()) {
|
||||
auto const& p = peerClosedHistory.front();
|
||||
if (p.first < now() - FLOW_KNOBS->HEALTH_MONITOR_CLIENT_REQUEST_INTERVAL_SECS) {
|
||||
auto& count = peerClosedNum[p.second];
|
||||
--count;
|
||||
ASSERT(count >= 0);
|
||||
++it; // Increment before pop_front to avoid iterator invalidation
|
||||
peerClosedHistory.pop_front();
|
||||
} else {
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue