async: DoH improvements

Adds a "meta_hash" to each easy handle for keeping special data during
operations. All meta data set needs to add its destructor callback, so
that meta data gets destroyed properly when the easy handle is cleaned
up or reset.

Add data->master_mid for "sub" transfers that belong to a "master" easy
handle. When a "sub" transfer is done, the corresponding "master" can
add a callback to be invoked. Used in DoH name resolution.

DoH: use easy meta hash to add internal structs for DoH name resolution.
One in each in each probe easy handle. When probes are done, response
data is copied from the probe to the initiating easy.

This allows DoH using transfers and their probes to be cleaned up in any
sequence correctly.

Fold DoH cleanup into the Curl_async_shutdown() and Curl_async_destroy()
functions.

Closes #16384
This commit is contained in:
Stefan Eissing 2025-04-16 13:45:53 +02:00 committed by Daniel Stenberg
parent 8478365e29
commit 1ebd92d0fd
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
14 changed files with 357 additions and 138 deletions

View file

@ -59,15 +59,6 @@ typedef enum {
DNS_TYPE_HTTPS = 65
} DNStype;
/* one of these for each DoH request */
struct doh_probe {
curl_off_t easy_mid; /* multi id of easy handle doing the lookup */
DNStype dnstype;
unsigned char req_body[512];
size_t req_body_len;
struct dynbuf resp_body;
};
enum doh_slot_num {
/* Explicit values for first two symbols so as to match hard-coded
* constants in existing code
@ -89,9 +80,29 @@ enum doh_slot_num {
DOH_SLOT_COUNT
};
struct doh_probes {
#define CURL_EZM_DOH_PROBE "ezm:doh-p"
/* each DoH probe request has this
* as easy meta for CURL_EZM_DOH_PROBE */
struct doh_request {
DNStype dnstype;
unsigned char req_body[512];
size_t req_body_len;
struct curl_slist *req_hds;
struct doh_probe probe[DOH_SLOT_COUNT];
struct dynbuf resp_body;
};
struct doh_response {
curl_off_t probe_mid;
struct dynbuf body;
DNStype dnstype;
CURLcode result;
};
/* each transfer firing off DoH requests has this
* as easy meta for CURL_EZM_DOH_MASTER */
struct doh_probes {
struct doh_response probe_resp[DOH_SLOT_COUNT];
unsigned int pending; /* still outstanding probes */
int port;
const char *host;