Skip to content

Async cleanup, dnscache move+correctness#20864

Closed
icing wants to merge 9 commits intocurl:masterfrom
icing:async-cleanup-dnscache-move
Closed

Async cleanup, dnscache move+correctness#20864
icing wants to merge 9 commits intocurl:masterfrom
icing:async-cleanup-dnscache-move

Conversation

@icing
Copy link
Copy Markdown
Contributor

@icing icing commented Mar 9, 2026

async improvements:

  • 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

dnscache: move to own source

  • 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.

async state allocated:

  • Make data->state.async a pointer instead of a struct. By addinghostname 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.

dnscache: observe ip version of cached entry

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.

@github-actions github-actions bot added the tests label Mar 9, 2026
@icing icing added feature-window A merge of this requires an open feature window name lookup DNS and related tech and removed tests labels Mar 9, 2026
@github-actions github-actions bot added the tests label Mar 9, 2026
@icing icing changed the title Async cleanup, dnscache move Async cleanup, dnscache move+correctness Mar 9, 2026
@icing icing force-pushed the async-cleanup-dnscache-move branch from 5934d4a to 1695e14 Compare March 16, 2026 09:38
@icing icing force-pushed the async-cleanup-dnscache-move branch from ad1c695 to 684e27a Compare March 16, 2026 13:31
icing added 8 commits March 18, 2026 10:50
- 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.
@icing icing force-pushed the async-cleanup-dnscache-move branch from 74f4eed to 4410070 Compare March 18, 2026 09:58
@bagder bagder closed this in 96d5b5c Mar 21, 2026
vszakats added a commit to vszakats/curl that referenced this pull request Mar 21, 2026
vszakats added a commit that referenced this pull request Mar 21, 2026
Include moved to `unitcheck.h` earlier.

Follow-up to 96d5b5c #20864
Ref: 8a1f361 #21024

Closes #21046
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature-window A merge of this requires an open feature window name lookup DNS and related tech tests

Development

Successfully merging this pull request may close these issues.

1 participant