Async cleanup, dnscache move+correctness#20864
Closed
icing wants to merge 9 commits intocurl:masterfrom
Closed
Conversation
5934d4a to
1695e14
Compare
ad1c695 to
684e27a
Compare
- Rename `Curl_resolv_unlink()` to `Curl_dns_entry_unlink()`. - Change `Curl_dnscache_get()` to return CURLcode result. Returns now `CURLE_COULDNT_RESOLVE_HOST` for "negative" cache entries. - Add `Curl_dnscache_add_negative()` to put a "negative" entry into the cache.
- Rename `Curl_doh_is_resolved()` to `Curl_doh_take_result()` to make clear this can only be called once successfully and deliver the result. - No longer keep the resolved dns entry at the async struct. It is delivered to the caller of `Curl_doh_take_result()` and not kept around. - use `uint16_t` for `port`, `uint8_t` for `ip_version` everywhere - remove `Curl_resolv_timeout()` and add a `timeout_ms` parameter to `Curl_resolv()` - hostip.c: split the alarm timeout resolve code from the "normal" resolve code for clarity
- Make `data->state.async` a pointer instead of a struct. By adding `hostname` to the struct allocation, this does not add a malloc. The benefit is that easy handle size shrinks. - Remove the separate `hostname` dups in ares and thrdd code. - Pass the `async` struct pointer to the resolve implemenations, so they do not have to go through the easy handle and have more "local" knowledge.
When caching dns entries, remember the `ip_version` used to resolve the entry. Only return a cached entry if it can provide answers to the `ip_version` looked up.
Check in DoH that an arriving response carries the matching async id. Otherwise, ignore the response. Add `data->state.next_async_id` to keep ids continuously increasing.
74f4eed to
4410070
Compare
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Mar 21, 2026
Follow-up to 96d5b5c curl#20864 Ref: 8a1f361 curl#21024
vszakats
added a commit
that referenced
this pull request
Mar 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
async improvements:
Curl_doh_is_resolved()toCurl_doh_take_result()to make clear this can only be called once successfully and deliver the result.Curl_doh_take_result()and not kept around.uint16_tforport,uint8_tforip_versioneverywhereCurl_resolv_timeout()and add atimeout_msparameter toCurl_resolv()dnscache: move to own source
Curl_resolv_unlink()toCurl_dns_entry_unlink().Curl_dnscache_get()to return CURLcode result. Returns nowCURLE_COULDNT_RESOLVE_HOSTfor "negative" cache entries.Curl_dnscache_add_negative()to put a "negative" entry into the cache.async state allocated:
data->state.asynca pointer instead of a struct. By addinghostnameto the struct allocation, this does not add a malloc. The benefit is that easy handle size shrinks.hostnamedups in ares and thrdd code.asyncstruct pointer to the resolve implemenations, so they do not have to go through the easy handle and have more "local" knowledge.dnscache: observe ip version of cached entry
When caching dns entries, remember the
ip_versionused to resolve the entry. Only return a cached entry if it can provide answers to theip_versionlooked up.