Skip to content

Commit

Permalink
advance map iterators with model_map_it_remove when removing items fr…
Browse files Browse the repository at this point in the history
…om iterated map (#822)
  • Loading branch information
scareything committed Mar 6, 2024
1 parent 3ae6fb1 commit fda6af5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/ziti-tunnel-cbs/ziti_dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,22 +370,24 @@ void ziti_dns_deregister_intercept(void *intercept) {
dns_entry_t *e = model_map_it_value(it);
model_map_remove_key(&e->intercepts, &intercept, sizeof(intercept));
if (model_map_size(&e->intercepts) == 0 && (e->domain == NULL || model_map_size(&e->domain->intercepts) == 0)) {
model_map_remove(&ziti_dns.hostnames, e->name);
it = model_map_it_remove(it);
model_map_removel(&ziti_dns.ip_addresses, ip_2_ip4(&e->addr)->addr);
ZITI_LOG(DEBUG, "%zu active hostnames mapped to %zu IPs", model_map_size(&ziti_dns.hostnames), model_map_size(&ziti_dns.ip_addresses));
ZITI_LOG(INFO, "DNS mapping %s -> %s is now inactive", e->name, e->ip);
} else {
it = model_map_it_next(it);
}
it = model_map_it_next(it);
}

it = model_map_iterator(&ziti_dns.domains);
while (it != NULL) {
dns_domain_t *domain = model_map_it_value(it);
if (model_map_size(&domain->intercepts) == 0) {
model_map_remove(&ziti_dns.domains, domain->name);
it = model_map_it_remove(it);
ZITI_LOG(INFO, "wildcard domain[*%s] is now inactive", domain->name);
} else {
it = model_map_it_next(it);
}
it = model_map_it_next(it);
}
}

Expand Down

0 comments on commit fda6af5

Please sign in to comment.