Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CURLOPT_DNS_SERVERS setting cannot be cleared from a reused easy handle #16015

Closed
denizsokmen opened this issue Jan 15, 2025 · 2 comments
Closed
Assignees
Labels
libcurl API name lookup DNS and related tech

Comments

@denizsokmen
Copy link

I did this

I call curl_easy_reset() when the multi interface is done with an easy handle, put it back in a pool and recycle them as more requests are made. I may set CURLOPT_DNS_SERVERS on some of those depending on the situation.

I expected the following

A subsequent call to curl_easy_setopt(curl, CURLOPT_DNS_SERVERS, ""); when reusing or curl_easy_reset() to reset the ares channel to its default settings. However, asyn-ares.c says:

  /* If server is NULL or empty, this would purge all DNS servers
   * from ares library, which will cause any and all queries to fail.
   * So, just return OK if none are configured and do not actually make
   * any changes to c-ares. This lets c-ares use its defaults, which
   * it gets from the OS (for instance from /etc/resolv.conf on Linux).
   */

which is understandable. However, there seems to be no way to clear CURLOPT_DNS_SERVERS from an easy handle unless a brand new one is created, making reuse of the handle impossible.

curl/libcurl version

Any

operating system

Ubuntu 22

@bagder bagder self-assigned this Jan 15, 2025
@bagder bagder added name lookup DNS and related tech libcurl API labels Jan 15, 2025
bagder added a commit that referenced this issue Jan 16, 2025
Since c-ares has no function to restore this value to default, it
instead closes and re-inits the c-ares channel.

Reported-by: Deniz Sökmen
Fixes #16015
@bagder
Copy link
Member

bagder commented Jan 16, 2025

It would be great if you can test #16016 for your case

@denizsokmen
Copy link
Author

denizsokmen commented Jan 16, 2025

Hi @bagder ,

Thanks for the quick fix. It works when NULL is passed, however I put a comment as it seems to break the empty string behavior. seems intended

@bagder bagder closed this as completed in 13afb11 Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libcurl API name lookup DNS and related tech
Development

Successfully merging a pull request may close this issue.

2 participants