Skip to content

Commit

Permalink
fix premature return
Browse files Browse the repository at this point in the history
  • Loading branch information
markdroth committed Feb 7, 2025
1 parent dcfd5ef commit fd848ad
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/core/xds/xds_client/xds_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1812,20 +1812,21 @@ void XdsClient::MaybeRemoveUnsubscribedCacheEntriesForTypeLocked(
if (authority_state.xds_channels.back() == xds_channel) {
// Find type map.
auto type_it = authority_state.type_map.find(type);
if (type_it == authority_state.type_map.end()) return;
auto& resource_map = type_it->second;
// Remove the cache entry for any resource without watchers.
for (auto resource_it = resource_map.begin();
resource_it != resource_map.end();) {
ResourceState& resource_state = resource_it->second;
if (!resource_state.HasWatchers()) {
resource_map.erase(resource_it++);
} else {
++resource_it;
if (type_it != authority_state.type_map.end()) {
auto& resource_map = type_it->second;
// Remove the cache entry for any resource without watchers.
for (auto resource_it = resource_map.begin();
resource_it != resource_map.end();) {
ResourceState& resource_state = resource_it->second;
if (!resource_state.HasWatchers()) {
resource_map.erase(resource_it++);
} else {
++resource_it;
}
}
// Clean up empty entries in the map.
if (resource_map.empty()) authority_state.type_map.erase(type_it);
}
// Clean up empty entries in the map.
if (resource_map.empty()) authority_state.type_map.erase(type_it);
}
if (authority_state.type_map.empty()) {
authority_state_map_.erase(authority_it++);
Expand Down

0 comments on commit fd848ad

Please sign in to comment.