mirror of
https://github.com/curl/curl.git
synced 2026-04-11 12:01:42 +08:00
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:
parent
a28540787c
commit
ef49d42a2c
@ -306,7 +306,7 @@ static CURLcode cf_dns_cntrl(struct Curl_cfilter *cf,
|
||||
|
||||
struct Curl_cftype Curl_cft_dns = {
|
||||
"DNS",
|
||||
0,
|
||||
CF_TYPE_SETUP,
|
||||
CURL_LOG_LVL_NONE,
|
||||
cf_dns_destroy,
|
||||
cf_dns_connect,
|
||||
|
||||
@ -185,7 +185,7 @@ static CURLcode cf_haproxy_adjust_pollset(struct Curl_cfilter *cf,
|
||||
|
||||
struct Curl_cftype Curl_cft_haproxy = {
|
||||
"HAPROXY",
|
||||
CF_TYPE_PROXY,
|
||||
CF_TYPE_PROXY | CF_TYPE_SETUP,
|
||||
0,
|
||||
cf_haproxy_destroy,
|
||||
cf_haproxy_connect,
|
||||
|
||||
@ -743,7 +743,7 @@ static void cf_hc_destroy(struct Curl_cfilter *cf, struct Curl_easy *data)
|
||||
|
||||
struct Curl_cftype Curl_cft_http_connect = {
|
||||
"HTTPS-CONNECT",
|
||||
0,
|
||||
CF_TYPE_SETUP,
|
||||
CURL_LOG_LVL_NONE,
|
||||
cf_hc_destroy,
|
||||
cf_hc_connect,
|
||||
|
||||
@ -958,7 +958,7 @@ static void cf_ip_happy_destroy(struct Curl_cfilter *cf,
|
||||
|
||||
struct Curl_cftype Curl_cft_ip_happy = {
|
||||
"HAPPY-EYEBALLS",
|
||||
0,
|
||||
CF_TYPE_SETUP,
|
||||
CURL_LOG_LVL_NONE,
|
||||
cf_ip_happy_destroy,
|
||||
cf_ip_happy_connect,
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -199,12 +199,15 @@ typedef CURLcode Curl_cft_query(struct Curl_cfilter *cf,
|
||||
* CF_TYPE_MULTIPLEX: provides multiplexing of easy handles
|
||||
* CF_TYPE_PROXY provides proxying
|
||||
* CF_TYPE_HTTP implement a version of the HTTP protocol
|
||||
* CF_TYPE_SETUP filter is only needed for connection setup and
|
||||
* can be removed once connected
|
||||
*/
|
||||
#define CF_TYPE_IP_CONNECT (1 << 0)
|
||||
#define CF_TYPE_SSL (1 << 1)
|
||||
#define CF_TYPE_MULTIPLEX (1 << 2)
|
||||
#define CF_TYPE_PROXY (1 << 3)
|
||||
#define CF_TYPE_HTTP (1 << 4)
|
||||
#define CF_TYPE_SETUP (1 << 5)
|
||||
|
||||
/* A connection filter type, e.g. specific implementation. */
|
||||
struct Curl_cftype {
|
||||
|
||||
@ -391,7 +391,7 @@ static void http_proxy_cf_close(struct Curl_cfilter *cf,
|
||||
|
||||
struct Curl_cftype Curl_cft_http_proxy = {
|
||||
"HTTP-PROXY",
|
||||
CF_TYPE_IP_CONNECT | CF_TYPE_PROXY,
|
||||
CF_TYPE_IP_CONNECT | CF_TYPE_PROXY | CF_TYPE_SETUP,
|
||||
0,
|
||||
http_proxy_cf_destroy,
|
||||
http_proxy_cf_connect,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user