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

asyn-ares: resolver timeout follows the c-ares mechanism #12703

Closed
wants to merge 1 commit into from

Conversation

sunlin7
Copy link
Contributor

@sunlin7 sunlin7 commented Jan 15, 2024

Hi,
The curl should set c-ares's timeout only for c-ares < 1.20.0.

curl use a fixed timeout=2s for c-ares from commit:
a181b4a,
actually c-ares used default timeout to 2s since c-ares-1.20.0 release (also mentioned on prevous commit).
c-ares/c-ares#542
and the timeout=2 from curl will overwrite the option: timeout from the /etc/resolv.conf, which supported since c-ares-1.23.0:
https://github.com/c-ares/c-ares/pull/632/files

So setting c-ares timeout to 2s should only apply to old c-ares < 1.20.0, won't overwrite timeout for c-ares > 1.23.0.

@github-actions github-actions bot added the name lookup DNS and related tech label Jan 15, 2024
@bagder
Copy link
Member

bagder commented Jan 15, 2024

The curl should set c-ares's timeout only for c-ares < 1.20.0.

Why? It risks/makes the timeouts to be different with different c-ares versions. Why do curl users want that?

Also, this patch checks the version of c--ares used when building curl, not the version that is actually used in run-time. That might not be the same...

@sunlin7
Copy link
Contributor Author

sunlin7 commented Jan 15, 2024

@bagder

Why? It risks/makes the timeouts to be different with different c-ares versions. Why do curl users want that?

curl failed example (curl 8.4+, c-ares 1.24+):

  1. user config DNS timeout in /etc/resolv.conf with options timeout:1 for DNS timeout 1 second
  2. first DNS service down (or un-accessable IP address eg: 10.10.10.10, to trigger timeout case)
  3. time ./curl http://www.google.com then will timeout for 2 seconds.
    Expected timeout is 1 second, for user had set timeout in resolv.conf file.
    This PR will let curl follow user timeout setting.

Also, this patch checks the version of c--ares used when building curl, not the version that is actually used in run-time. That might not be the same...

It's already there: curl-8.3 with c-ares the DNS timeout is 5 seconds; while curl-8.4 with c-ares timeout is 2 seconds.

I like to change curl to get the version from loaded libcares dynamicly, give me minutes.

@sunlin7
Copy link
Contributor Author

sunlin7 commented Jan 15, 2024

Hi @bagder
I pushed the changed one that getting the version from loaded libcares, please help review again, thanks.

@bagder
Copy link
Member

bagder commented Jan 15, 2024

user config DNS timeout in /etc/resolv.conf with options timeout:1 for DNS timeout 1 second

I did not even know that thing existed.

This then begs the question: what if we want to set the limit to N seconds but allow /etc/resolv.conf to override if set. Is that then not possible, you know?

@sunlin7
Copy link
Contributor Author

sunlin7 commented Jan 16, 2024

Hi @bagder
This change is strong enough:
if libares < 1.20.0: curl set timeout to 2s;
if libares >= 1.20.0 it already has the timeout to 2s, curl don't need to set the timeout value;
if libares >= 1.24.0, user can set the timeout via /etc/resolv.conf to overwrite the libares's default timeout.

This then begs the question: what if we want to set the limit to N seconds but allow /etc/resolv.conf to override if set. Is that then not possible, you know?

Currently no grace way to do that (unless we parse the /etc/resolv.conf, but that's not curl's scope.)

@bagder bagder closed this in 4224d6e Jan 16, 2024
@bagder
Copy link
Member

bagder commented Jan 16, 2024

thanks!

@sunlin7
Copy link
Contributor Author

sunlin7 commented Jan 16, 2024

Thank you !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
name lookup DNS and related tech
Development

Successfully merging this pull request may close these issues.

None yet

2 participants