]> git.ipfire.org Git - thirdparty/curl.git/commit
asyn resolver code improvements
authorStefan Eissing <stefan@eissing.org>
Fri, 11 Apr 2025 12:43:45 +0000 (14:43 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 16 Apr 2025 07:34:20 +0000 (09:34 +0200)
commit56e40ae6a532850b5037ccfb528ed44f09f3d484
tree46b800da0059bc4859c32dab1dbe51c8142137ee
parentbe718daf995b620dd8bf89d725d1c4c031b3840a
asyn resolver code improvements

"asyn" is the internal name under which both c-ares and threaded
resolver operate. Make the naming more consistent. Implement the c-ares
resolver in `asyn-ares.*` and the threaded resolver in `asyn-thrdd.*`.
The common functions are in `asyn-base.c`.

When `CURLRES_ASYNCH` is defined, either of the two is used and
`data->state.async` exists. Members of that struct vary for the selected
implementation, but have the fields `hostname`, `port` and `ip_version`
always present. This are populated when the async resolving starts and
eliminate the need to pass them again when checking on the status and
processing the results of the resolving.

Add a `Curl_resolv_blocking()` to `hostip.h` that relieves FTP and SOCKS
from having to repeat the same code.

`Curl_resolv_check()` remains the function to check for status of
ongoing resolving. Now it also performs internally the check if the
needed DNS entry exists in the dnscache and if so, aborts the asnyc
operation. (libcurl right now does not check for duplicate resolve
attempts. an area for future improvements).

The number of functions in `asyn.h` has been reduced. There were subtle
difference in "cancel()" and "kill()" calls, both replaced by
`Curl_async_shutdown()` now. This changes behaviour for threaded
resolver insofar as the resolving thread is now always joined unless
`data->set.quick_exit` is set. Before this was only done on some code
paths. A future improvement would be a thread pool that keeps a limit
and also could handle joins more gracefully.

DoH, not previously tagged under "asny", has its struct `doh_probes` now
also in `data->state.async`, moved there from `data->req` because it
makes more sense. Further integration of DoH underneath the "asyn"
umbrella seems like a good idea.

Closes #16963
30 files changed:
lib/Makefile.inc
lib/asyn-ares.c
lib/asyn-base.c [new file with mode: 0644]
lib/asyn-thrdd.c [new file with mode: 0644]
lib/asyn-thread.c [deleted file]
lib/asyn.h
lib/cf-socket.c
lib/cshutdn.c
lib/doh.c
lib/doh.h
lib/easy.c
lib/ftp.c
lib/hostasyn.c [deleted file]
lib/hostip.c
lib/hostip.h
lib/hostip4.c
lib/hostip6.c
lib/hostsyn.c [deleted file]
lib/httpsrr.c
lib/httpsrr.h
lib/multi.c
lib/request.h
lib/setopt.c
lib/socks.c
lib/url.c
lib/urldata.h
lib/vtls/openssl.c
lib/vtls/rustls.c
lib/vtls/wolfssl.c
tests/http/scorecard.py