Skip to content

Commit

Permalink
dns: Handle active DNS entries before clearing cache
Browse files Browse the repository at this point in the history
Issue:
A bug was identified where calling dns_clear_cache() after a DNS query request
but before the query response is received causes the dns_clear_cache() function
to clear the dns_table database. This results in the netconn layer
waiting indefinitely for the dns_call_found() callback, leading to a deadlock.

Resolution:
Added logic to invoke dns_call_found() for any active DNS entries before
clearing the entire DNS cache in the dns_clear_cache() function.
This change ensures that in-use entries are handled properly,
preventing the system from entering a deadlock state.
  • Loading branch information
espressif-abhikroy committed Oct 8, 2024
1 parent f150e23 commit b15cd2d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/core/dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,13 @@ dns_setserver(u8_t numdns, const ip_addr_t *dnsserver)
void
dns_clear_cache(void)
{
u8_t i=0;
for (i = 0; i < DNS_TABLE_SIZE; i++) {
if (dns_table[i].state != DNS_STATE_UNUSED) {
dns_call_found(i, NULL);
}
}

memset(dns_table, 0, sizeof(struct dns_table_entry) * DNS_TABLE_SIZE);
}

Expand Down

0 comments on commit b15cd2d

Please sign in to comment.