Skip to content

Commit

Permalink
remove dns client's active requests from ziti_dns.requests when closi…
Browse files Browse the repository at this point in the history
…ng client
  • Loading branch information
scareything committed Sep 19, 2024
1 parent aa083dc commit 492d307
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/ziti-tunnel-cbs/ziti_dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,19 @@ void* on_dns_client(const void *app_intercept_ctx, io_ctx_t *io) {
return clt;
}

static void remove_dns_req(void *p) {
struct dns_req *req = p;
if (req) {
model_map_remove_key(&ziti_dns.requests, &req->id, sizeof(req->id));
}
}

int on_dns_close(void *dns_io_ctx) {
ZITI_LOG(TRACE, "DNS client close");
ziti_dns_client_t *clt = dns_io_ctx;
model_map_clear(&clt->active_reqs, NULL);
// we may be here due to udp timeout, and reqs may have been sent to upstream.
// remove reqs from ziti_dns to prevent completion (with invalid io_ctx) if upstream should respond after udp timeout.
model_map_clear(&clt->active_reqs, remove_dns_req);
ziti_tunneler_close(clt->io_ctx->tnlr_io);
free(clt->io_ctx);
free(dns_io_ctx);
Expand Down

0 comments on commit 492d307

Please sign in to comment.