mirror of
https://github.com/curl/curl.git
synced 2026-04-15 07:31:41 +03:00
dns_entry: move from conn to data->state
The `struct Curl_dns_entry *` used to established a connection do not have the connection's lifetime, but the transfer's lifetime (of the transfer that initiates the connect). `Curl_dns_entry *` is reference counted with the "dns cache". That cache might be owned by the multi or the transfer's share. In the share, the reference count needs updating under lock. Therefore, the dns entry can only be kept *and* released using the same transfer it was initially looked up from. But a connection is often discarded using another transfer. So far, the problem of this has been avoided in clearing the connection's dns entries in the "multi_don()" handling. So, connections had NULL dns entries after the initial transfers and its connect had been handled. Keeping the dns entries in data->state seems therefore a better choice. Also: remove the `struct Curl_dns_entry *` from the connect filters contexts. Use `data->state.dns` every time instead and fail correctly when not present and needed. Closes #17383
This commit is contained in:
parent
3ec6aa5c07
commit
be45e014c6
14 changed files with 132 additions and 119 deletions
|
|
@ -113,7 +113,6 @@ static CURLcode cf_hc_baller_cntrl(struct cf_hc_baller *b,
|
|||
|
||||
struct cf_hc_ctx {
|
||||
cf_hc_state state;
|
||||
const struct Curl_dns_entry *remotehost;
|
||||
struct curltime started; /* when connect started */
|
||||
CURLcode result; /* overall result */
|
||||
struct cf_hc_baller ballers[2];
|
||||
|
|
@ -147,7 +146,6 @@ static void cf_hc_baller_init(struct cf_hc_baller *b,
|
|||
struct Curl_easy *data,
|
||||
int transport)
|
||||
{
|
||||
struct cf_hc_ctx *ctx = cf->ctx;
|
||||
struct Curl_cfilter *save = cf->next;
|
||||
|
||||
cf->next = NULL;
|
||||
|
|
@ -161,8 +159,8 @@ static void cf_hc_baller_init(struct cf_hc_baller *b,
|
|||
}
|
||||
|
||||
if(!b->result)
|
||||
b->result = Curl_cf_setup_insert_after(cf, data, ctx->remotehost,
|
||||
transport, CURL_CF_SSL_ENABLE);
|
||||
b->result = Curl_cf_setup_insert_after(cf, data, transport,
|
||||
CURL_CF_SSL_ENABLE);
|
||||
b->cf = cf->next;
|
||||
cf->next = save;
|
||||
}
|
||||
|
|
@ -576,7 +574,6 @@ struct Curl_cftype Curl_cft_http_connect = {
|
|||
|
||||
static CURLcode cf_hc_create(struct Curl_cfilter **pcf,
|
||||
struct Curl_easy *data,
|
||||
const struct Curl_dns_entry *remotehost,
|
||||
enum alpnid *alpnids, size_t alpn_count)
|
||||
{
|
||||
struct Curl_cfilter *cf = NULL;
|
||||
|
|
@ -598,7 +595,6 @@ static CURLcode cf_hc_create(struct Curl_cfilter **pcf,
|
|||
result = CURLE_OUT_OF_MEMORY;
|
||||
goto out;
|
||||
}
|
||||
ctx->remotehost = remotehost;
|
||||
for(i = 0; i < alpn_count; ++i)
|
||||
cf_hc_baller_assign(&ctx->ballers[i], alpnids[i]);
|
||||
for(; i < CURL_ARRAYSIZE(ctx->ballers); ++i)
|
||||
|
|
@ -620,14 +616,13 @@ out:
|
|||
static CURLcode cf_http_connect_add(struct Curl_easy *data,
|
||||
struct connectdata *conn,
|
||||
int sockindex,
|
||||
const struct Curl_dns_entry *remotehost,
|
||||
enum alpnid *alpn_ids, size_t alpn_count)
|
||||
{
|
||||
struct Curl_cfilter *cf;
|
||||
CURLcode result = CURLE_OK;
|
||||
|
||||
DEBUGASSERT(data);
|
||||
result = cf_hc_create(&cf, data, remotehost, alpn_ids, alpn_count);
|
||||
result = cf_hc_create(&cf, data, alpn_ids, alpn_count);
|
||||
if(result)
|
||||
goto out;
|
||||
Curl_conn_cf_add(data, conn, sockindex, cf);
|
||||
|
|
@ -648,8 +643,7 @@ static bool cf_https_alpns_contain(enum alpnid id,
|
|||
|
||||
CURLcode Curl_cf_https_setup(struct Curl_easy *data,
|
||||
struct connectdata *conn,
|
||||
int sockindex,
|
||||
const struct Curl_dns_entry *remotehost)
|
||||
int sockindex)
|
||||
{
|
||||
enum alpnid alpn_ids[2];
|
||||
size_t alpn_count = 0;
|
||||
|
|
@ -657,7 +651,6 @@ CURLcode Curl_cf_https_setup(struct Curl_easy *data,
|
|||
struct Curl_cfilter cf_fake, *cf = NULL;
|
||||
|
||||
(void)sockindex;
|
||||
(void)remotehost;
|
||||
/* we want to log for the filter before we create it, fake it. */
|
||||
memset(&cf_fake, 0, sizeof(cf_fake));
|
||||
cf_fake.cft = &Curl_cft_http_connect;
|
||||
|
|
@ -669,7 +662,8 @@ CURLcode Curl_cf_https_setup(struct Curl_easy *data,
|
|||
* We are here after having selected a connection to a host+port and
|
||||
* can no longer change that. Any HTTPSRR advice for other hosts and ports
|
||||
* we need to ignore. */
|
||||
struct Curl_https_rrinfo *rr = remotehost ? remotehost->hinfo : NULL;
|
||||
struct Curl_dns_entry *dns = data->state.dns[sockindex];
|
||||
struct Curl_https_rrinfo *rr = dns ? dns->hinfo : NULL;
|
||||
if(rr && !rr->no_def_alpn && /* ALPNs are defaults */
|
||||
(!rr->target || /* for same host */
|
||||
!rr->target[0] ||
|
||||
|
|
@ -739,8 +733,7 @@ CURLcode Curl_cf_https_setup(struct Curl_easy *data,
|
|||
/* If we identified ALPNs to use, install our filter. Otherwise,
|
||||
* install nothing, so our call will use a default connect setup. */
|
||||
if(alpn_count) {
|
||||
result = cf_http_connect_add(data, conn, sockindex, remotehost,
|
||||
alpn_ids, alpn_count);
|
||||
result = cf_http_connect_add(data, conn, sockindex, alpn_ids, alpn_count);
|
||||
}
|
||||
|
||||
out:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue