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

Async DNS resolution on Win8+ with GetAddrInfoExW #12481

Closed
pps83 opened this issue Dec 7, 2023 · 3 comments
Closed

Async DNS resolution on Win8+ with GetAddrInfoExW #12481

pps83 opened this issue Dec 7, 2023 · 3 comments
Labels
feature-request memory-leak name lookup DNS and related tech Windows Windows-specific

Comments

@pps83
Copy link
Contributor

pps83 commented Dec 7, 2023

I did this

I tried to run a test on Windows under asan where many fetches are tried when there is no internet. It appears that starting/exiting threads under asan leaks memory badly, it takes only a few seconds before all ram gets consumed.

I expected the following

Although, this isn't a bug in libcurl, but in my case I had to fix the issue. It seems that libcurl without c-ares always starts a thread for dns requests since dns was always blocking before Win8. Starting from Win8 there is a non-blocking version is available with GetAddrInfoExW.
Alternatively, libcurl could have cached failed dns results for a very short time to avoid redoing the same requests multiple times: for example, if 1000 requests are made to the same host while there is no connection instead of starting 1000 threads in 10ms doing the same failing dns request it would be better to cache failures for 10ms or 1ms.

In my case, I ended up writing code that uses GetAddrInfoExW on Win8. Let me know if it's something worth to add to libcurl, and I'll make a PR.

curl/libcurl version

curl 8.5.0

operating system

WIndows 8+

@bagder bagder added memory-leak name lookup DNS and related tech labels Dec 7, 2023
@bagder
Copy link
Member

bagder commented Dec 7, 2023

see #12406 for pending "negative caching"

@bagder bagder added the Windows Windows-specific label Dec 7, 2023
@bagder
Copy link
Member

bagder commented Dec 7, 2023

In my case, I ended up writing code that uses GetAddrInfoExW on Win8. Let me know if it's something worth to add to libcurl, and I'll make a PR.

By your description it certainly sounds like a worthwhile idea. Please do!

@pps83
Copy link
Contributor Author

pps83 commented Dec 7, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request memory-leak name lookup DNS and related tech Windows Windows-specific
Development

No branches or pull requests

2 participants