Skip to content

Conversation

@zafersn
Copy link
Contributor

@zafersn zafersn commented Nov 7, 2025

dns_resolve_close() fails to clean up DNS server slots when the context state is DNS_RESOLVE_CONTEXT_INACTIVE, leaving stale server configuration data that causes subsequent dns_resolve_init() calls to incorrectly detect "server already exists" and skip socket creation, breaking DNS resolution.

#99089

Signed-off-by: Zafer SEN [email protected]

@zafersn zafersn changed the title Fix/dns resolve cleanup inactive state subsys: net: lib: dns: resolve Fix/dns resolve cleanup inactive state Nov 7, 2025
@zafersn zafersn force-pushed the fix/dns-resolve-cleanup-inactive-state branch 2 times, most recently from f874dff to 6715042 Compare November 7, 2025 15:29
dns_resolve_close() fails to clean up server slots when the
context is in DNS_RESOLVE_CONTEXT_INACTIVE state.

Signed-off-by: Zafer SEN <[email protected]>
@zafersn zafersn force-pushed the fix/dns-resolve-cleanup-inactive-state branch from 6715042 to 83bf832 Compare November 7, 2025 16:09
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 7, 2025

@zafersn
Copy link
Contributor Author

zafersn commented Nov 8, 2025

Closing PR: Root Cause Was Application-Level

After thorough debugging, we've determined that this PR is not needed. The issue we encountered was caused by our application code directly manipulating the DNS context internal state, which is not the intended usage of the DNS resolver API.

What happened:

Our modem driver was setting dnsCtx->state = DNS_RESOLVE_CONTEXT_INACTIVE directly during modem power cycles, bypassing the normal cleanup flow. This left resources (socket dispatcher registrations) in an inconsistent state.

Proper fix:

The correct approach is to:

Call dns_resolve_close() before shutting down the modem/socket
Never directly modify internal dns_resolve_context state fields
Let the DNS resolver manage its own state machine
After fixing our application code to properly use the DNS resolver API, the issue is resolved without any changes needed to Zephyr.

Apologies:

Sorry for the unnecessary PR. This was a case of improper API usage on our end, not a Zephyr bug. We've learned to always respect the abstraction boundaries and use the provided APIs correctly.

Closing this PR.

@zafersn zafersn closed this Nov 8, 2025
@zafersn zafersn deleted the fix/dns-resolve-cleanup-inactive-state branch November 8, 2025 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants