cfilters: CF_TYPE_SETUP connection filter

Connection filters can now carry the flag CF_TYPE_SETUP, indicating that
they are only needed during connection setup, e.g. connect.

Once the connection is fully established, those filter are removed
again. This frees resources and also makes the filter (call) chains
shorter.

Closes #21269
This commit is contained in:
Stefan Eissing 2026-04-08 14:37:45 +02:00 committed by Daniel Stenberg
parent a28540787c
commit ef49d42a2c
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
7 changed files with 27 additions and 5 deletions

View file

@ -491,6 +491,24 @@ static void conn_report_connect_stats(struct Curl_cfilter *cf,
}
}
static void conn_remove_setup_filters(struct Curl_easy *data,
int sockindex)
{
struct Curl_cfilter **anchor = &data->conn->cfilter[sockindex];
while(*anchor) {
struct Curl_cfilter *cf = *anchor;
if(cf->connected && (cf->cft->flags & CF_TYPE_SETUP)) {
*anchor = cf->next;
cf->next = NULL;
CURL_TRC_CF(data, cf, "removing connected setup filter");
cf->cft->destroy(cf, data);
curlx_free(cf);
}
else
anchor = &cf->next;
}
}
CURLcode Curl_conn_connect(struct Curl_easy *data,
int sockindex,
bool blocking,
@ -544,6 +562,7 @@ CURLcode Curl_conn_connect(struct Curl_easy *data,
conn_report_connect_stats(cf, data);
data->conn->keepalive = *Curl_pgrs_now(data);
VERBOSE(result = cf_verboseconnect(data, cf));
conn_remove_setup_filters(data, sockindex);
goto out;
}
else if(result) {