mirror of
https://github.com/curl/curl.git
synced 2026-06-02 17:54:52 +03:00
cfilters: remove close method
closing a filter chain and reconnecting it again is a complication that only the HTTP/1.x proxy filter used. Remove it from all filters. Instead, a filter can return CURLE_AGAIN during the connect phase and the cf-setup filter will tear down all "sub filters" and restart over. With this, a filter never resets to the initial phase but progresses through connect -> connected -> shutdown -> destroy once. Closes #21831
This commit is contained in:
parent
ba600296d2
commit
31cb54e1fa
21 changed files with 50 additions and 296 deletions
|
|
@ -59,24 +59,6 @@ static void capsule_cf_destroy(struct Curl_cfilter *cf,
|
|||
}
|
||||
}
|
||||
|
||||
static void capsule_cf_close(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data)
|
||||
{
|
||||
struct cf_capsule_ctx *ctx = cf->ctx;
|
||||
|
||||
CURL_TRC_CF(data, cf, "close");
|
||||
cf->connected = FALSE;
|
||||
if(ctx) {
|
||||
Curl_bufq_reset(&ctx->recvbuf);
|
||||
curlx_safefree(ctx->pending);
|
||||
ctx->pending_len = 0;
|
||||
ctx->pending_offset = 0;
|
||||
ctx->pending_payload = 0;
|
||||
}
|
||||
if(cf->next)
|
||||
cf->next->cft->do_close(cf->next, data);
|
||||
}
|
||||
|
||||
static CURLcode capsule_cf_connect(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data,
|
||||
bool *done)
|
||||
|
|
@ -212,7 +194,6 @@ struct Curl_cftype Curl_cft_capsule = {
|
|||
0,
|
||||
capsule_cf_destroy,
|
||||
capsule_cf_connect,
|
||||
capsule_cf_close,
|
||||
Curl_cf_def_shutdown,
|
||||
Curl_cf_def_adjust_pollset,
|
||||
capsule_cf_data_pending,
|
||||
|
|
|
|||
|
|
@ -310,13 +310,6 @@ static void cf_dns_destroy(struct Curl_cfilter *cf, struct Curl_easy *data)
|
|||
cf_dns_ctx_destroy(data, ctx);
|
||||
}
|
||||
|
||||
static void cf_dns_close(struct Curl_cfilter *cf, struct Curl_easy *data)
|
||||
{
|
||||
cf->connected = FALSE;
|
||||
if(cf->next)
|
||||
cf->next->cft->do_close(cf->next, data);
|
||||
}
|
||||
|
||||
static CURLcode cf_dns_adjust_pollset(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data,
|
||||
struct easy_pollset *ps)
|
||||
|
|
@ -362,7 +355,6 @@ struct Curl_cftype Curl_cft_dns = {
|
|||
CURL_LOG_LVL_NONE,
|
||||
cf_dns_destroy,
|
||||
cf_dns_connect,
|
||||
cf_dns_close,
|
||||
Curl_cf_def_shutdown,
|
||||
cf_dns_adjust_pollset,
|
||||
Curl_cf_def_data_pending,
|
||||
|
|
|
|||
|
|
@ -757,9 +757,7 @@ static CURLcode H1_CONNECT(struct Curl_cfilter *cf,
|
|||
*/
|
||||
CURL_TRC_CF(data, cf, "CONNECT need to close+open");
|
||||
infof(data, "Connect me again please");
|
||||
Curl_conn_cf_close(cf, data);
|
||||
result = Curl_conn_cf_connect(cf->next, data, &done);
|
||||
return result;
|
||||
return CURLE_AGAIN;
|
||||
}
|
||||
else {
|
||||
/* staying on this connection, reset state */
|
||||
|
|
@ -905,18 +903,6 @@ static void cf_h1_proxy_destroy(struct Curl_cfilter *cf,
|
|||
curlx_safefree(cf->ctx);
|
||||
}
|
||||
|
||||
static void cf_h1_proxy_close(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data)
|
||||
{
|
||||
struct cf_h1_proxy_ctx *pctx = cf->ctx;
|
||||
CURL_TRC_CF(data, cf, "close");
|
||||
cf->connected = FALSE;
|
||||
if(pctx && pctx->ts)
|
||||
h1_tunnel_go_state(cf, pctx->ts, H1_TUNNEL_INIT, data);
|
||||
if(cf->next)
|
||||
cf->next->cft->do_close(cf->next, data);
|
||||
}
|
||||
|
||||
static CURLcode cf_h1_proxy_query(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data,
|
||||
int query, int *pres1, void *pres2)
|
||||
|
|
@ -950,7 +936,6 @@ struct Curl_cftype Curl_cft_h1_proxy = {
|
|||
0,
|
||||
cf_h1_proxy_destroy,
|
||||
cf_h1_proxy_connect,
|
||||
cf_h1_proxy_close,
|
||||
Curl_cf_def_shutdown,
|
||||
cf_h1_proxy_adjust_pollset,
|
||||
cf_h1_proxy_data_pending,
|
||||
|
|
|
|||
|
|
@ -1034,21 +1034,6 @@ out:
|
|||
return result;
|
||||
}
|
||||
|
||||
static void cf_h2_proxy_close(struct Curl_cfilter *cf, struct Curl_easy *data)
|
||||
{
|
||||
struct cf_h2_proxy_ctx *ctx = cf->ctx;
|
||||
|
||||
if(ctx) {
|
||||
struct cf_call_data save;
|
||||
|
||||
CF_DATA_SAVE(save, cf, data);
|
||||
cf_h2_proxy_ctx_clear(ctx);
|
||||
CF_DATA_RESTORE(cf, save);
|
||||
}
|
||||
if(cf->next)
|
||||
cf->next->cft->do_close(cf->next, data);
|
||||
}
|
||||
|
||||
static void cf_h2_proxy_destroy(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data)
|
||||
{
|
||||
|
|
@ -1484,7 +1469,6 @@ struct Curl_cftype Curl_cft_h2_proxy = {
|
|||
CURL_LOG_LVL_NONE,
|
||||
cf_h2_proxy_destroy,
|
||||
cf_h2_proxy_connect,
|
||||
cf_h2_proxy_close,
|
||||
cf_h2_proxy_shutdown,
|
||||
cf_h2_proxy_adjust_pollset,
|
||||
cf_h2_proxy_data_pending,
|
||||
|
|
|
|||
|
|
@ -3374,24 +3374,6 @@ static void cf_h3_proxy_destroy(struct Curl_cfilter *cf,
|
|||
}
|
||||
}
|
||||
|
||||
static void cf_h3_proxy_close(struct Curl_cfilter *cf, struct Curl_easy *data)
|
||||
{
|
||||
struct cf_h3_proxy_ctx *ctx = cf->ctx;
|
||||
|
||||
if(ctx) {
|
||||
if(ctx->ngtcp2_ctx) {
|
||||
cf_ngtcp2_proxy_close(cf, data);
|
||||
cf_ngtcp2_proxy_ctx_free(ctx->ngtcp2_ctx);
|
||||
ctx->ngtcp2_ctx = NULL;
|
||||
}
|
||||
cf_h3_proxy_ctx_clear(ctx);
|
||||
cf->connected = FALSE;
|
||||
}
|
||||
|
||||
if(cf->next)
|
||||
cf->next->cft->do_close(cf->next, data);
|
||||
}
|
||||
|
||||
static CURLcode cf_h3_proxy_shutdown(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data, bool *done)
|
||||
{
|
||||
|
|
@ -3404,7 +3386,6 @@ struct Curl_cftype Curl_cft_h3_proxy = {
|
|||
CURL_LOG_LVL_NONE,
|
||||
cf_h3_proxy_destroy,
|
||||
cf_h3_proxy_connect,
|
||||
cf_h3_proxy_close,
|
||||
cf_h3_proxy_shutdown,
|
||||
cf_h3_proxy_adjust_pollset,
|
||||
cf_h3_proxy_data_pending,
|
||||
|
|
|
|||
|
|
@ -45,13 +45,6 @@ struct cf_haproxy_ctx {
|
|||
struct dynbuf data_out;
|
||||
};
|
||||
|
||||
static void cf_haproxy_ctx_reset(struct cf_haproxy_ctx *ctx)
|
||||
{
|
||||
DEBUGASSERT(ctx);
|
||||
ctx->state = HAPROXY_INIT;
|
||||
curlx_dyn_reset(&ctx->data_out);
|
||||
}
|
||||
|
||||
static void cf_haproxy_ctx_free(struct cf_haproxy_ctx *ctx)
|
||||
{
|
||||
if(ctx) {
|
||||
|
|
@ -173,16 +166,6 @@ static void cf_haproxy_destroy(struct Curl_cfilter *cf,
|
|||
cf_haproxy_ctx_free(cf->ctx);
|
||||
}
|
||||
|
||||
static void cf_haproxy_close(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data)
|
||||
{
|
||||
CURL_TRC_CF(data, cf, "close");
|
||||
cf->connected = FALSE;
|
||||
cf_haproxy_ctx_reset(cf->ctx);
|
||||
if(cf->next)
|
||||
cf->next->cft->do_close(cf->next, data);
|
||||
}
|
||||
|
||||
static CURLcode cf_haproxy_adjust_pollset(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data,
|
||||
struct easy_pollset *ps)
|
||||
|
|
@ -202,7 +185,6 @@ struct Curl_cftype Curl_cft_haproxy = {
|
|||
0,
|
||||
cf_haproxy_destroy,
|
||||
cf_haproxy_connect,
|
||||
cf_haproxy_close,
|
||||
Curl_cf_def_shutdown,
|
||||
cf_haproxy_adjust_pollset,
|
||||
Curl_cf_def_data_pending,
|
||||
|
|
|
|||
|
|
@ -62,7 +62,6 @@ static void cf_hc_baller_discard(struct cf_hc_baller *b,
|
|||
struct Curl_easy *data)
|
||||
{
|
||||
if(b->cf) {
|
||||
Curl_conn_cf_close(b->cf, data);
|
||||
Curl_conn_cf_discard_chain(&b->cf, data);
|
||||
b->cf = NULL;
|
||||
}
|
||||
|
|
@ -731,18 +730,6 @@ out:
|
|||
return result;
|
||||
}
|
||||
|
||||
static void cf_hc_close(struct Curl_cfilter *cf, struct Curl_easy *data)
|
||||
{
|
||||
CURL_TRC_CF(data, cf, "close");
|
||||
cf_hc_ctx_close(data, cf->ctx);
|
||||
cf->connected = FALSE;
|
||||
|
||||
if(cf->next) {
|
||||
cf->next->cft->do_close(cf->next, data);
|
||||
Curl_conn_cf_discard_chain(&cf->next, data);
|
||||
}
|
||||
}
|
||||
|
||||
static void cf_hc_destroy(struct Curl_cfilter *cf, struct Curl_easy *data)
|
||||
{
|
||||
struct cf_hc_ctx *ctx = cf->ctx;
|
||||
|
|
@ -757,7 +744,6 @@ struct Curl_cftype Curl_cft_http_connect = {
|
|||
CURL_LOG_LVL_NONE,
|
||||
cf_hc_destroy,
|
||||
cf_hc_connect,
|
||||
cf_hc_close,
|
||||
cf_hc_shutdown,
|
||||
cf_hc_adjust_pollset,
|
||||
cf_hc_data_pending,
|
||||
|
|
|
|||
|
|
@ -891,22 +891,6 @@ out:
|
|||
return result;
|
||||
}
|
||||
|
||||
static void cf_ip_happy_close(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data)
|
||||
{
|
||||
struct cf_ip_happy_ctx *ctx = cf->ctx;
|
||||
|
||||
CURL_TRC_CF(data, cf, "close");
|
||||
cf_ip_happy_ctx_clear(cf, data);
|
||||
cf->connected = FALSE;
|
||||
ctx->state = SCFST_INIT;
|
||||
|
||||
if(cf->next) {
|
||||
cf->next->cft->do_close(cf->next, data);
|
||||
Curl_conn_cf_discard_chain(&cf->next, data);
|
||||
}
|
||||
}
|
||||
|
||||
static bool cf_ip_happy_data_pending(struct Curl_cfilter *cf,
|
||||
const struct Curl_easy *data)
|
||||
{
|
||||
|
|
@ -971,7 +955,6 @@ struct Curl_cftype Curl_cft_ip_happy = {
|
|||
CURL_LOG_LVL_NONE,
|
||||
cf_ip_happy_destroy,
|
||||
cf_ip_happy_connect,
|
||||
cf_ip_happy_close,
|
||||
cf_ip_happy_shutdown,
|
||||
cf_ip_happy_adjust_pollset,
|
||||
cf_ip_happy_data_pending,
|
||||
|
|
|
|||
|
|
@ -972,24 +972,6 @@ static CURLcode cf_socket_ctx_init(struct cf_socket_ctx *ctx,
|
|||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void cf_socket_close(struct Curl_cfilter *cf, struct Curl_easy *data)
|
||||
{
|
||||
struct cf_socket_ctx *ctx = cf->ctx;
|
||||
|
||||
if(ctx && ctx->sock != CURL_SOCKET_BAD) {
|
||||
CURL_TRC_CF(data, cf, "cf_socket_close, fd=%" FMT_SOCKET_T, ctx->sock);
|
||||
if(ctx->sock == cf->conn->sock[cf->sockindex])
|
||||
cf->conn->sock[cf->sockindex] = CURL_SOCKET_BAD;
|
||||
socket_close(data, cf->conn, !ctx->accepted, ctx->sock);
|
||||
ctx->sock = CURL_SOCKET_BAD;
|
||||
ctx->active = FALSE;
|
||||
memset(&ctx->started_at, 0, sizeof(ctx->started_at));
|
||||
memset(&ctx->connected_at, 0, sizeof(ctx->connected_at));
|
||||
}
|
||||
|
||||
cf->connected = FALSE;
|
||||
}
|
||||
|
||||
static CURLcode cf_socket_shutdown(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data,
|
||||
bool *done)
|
||||
|
|
@ -1016,10 +998,16 @@ static void cf_socket_destroy(struct Curl_cfilter *cf, struct Curl_easy *data)
|
|||
{
|
||||
struct cf_socket_ctx *ctx = cf->ctx;
|
||||
|
||||
cf_socket_close(cf, data);
|
||||
CURL_TRC_CF(data, cf, "destroy");
|
||||
curlx_free(ctx);
|
||||
cf->ctx = NULL;
|
||||
if(ctx) {
|
||||
if(ctx->sock != CURL_SOCKET_BAD) {
|
||||
CURL_TRC_CF(data, cf, "cf_socket_close, fd=%" FMT_SOCKET_T, ctx->sock);
|
||||
if(ctx->sock == cf->conn->sock[cf->sockindex])
|
||||
cf->conn->sock[cf->sockindex] = CURL_SOCKET_BAD;
|
||||
socket_close(data, cf->conn, !ctx->accepted, ctx->sock);
|
||||
}
|
||||
curlx_free(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
static void set_local_ip(struct Curl_cfilter *cf,
|
||||
|
|
@ -1752,7 +1740,6 @@ struct Curl_cftype Curl_cft_tcp = {
|
|||
CURL_LOG_LVL_NONE,
|
||||
cf_socket_destroy,
|
||||
cf_tcp_connect,
|
||||
cf_socket_close,
|
||||
cf_socket_shutdown,
|
||||
cf_socket_adjust_pollset,
|
||||
Curl_cf_def_data_pending,
|
||||
|
|
@ -1920,7 +1907,6 @@ struct Curl_cftype Curl_cft_udp = {
|
|||
CURL_LOG_LVL_NONE,
|
||||
cf_socket_destroy,
|
||||
cf_udp_connect,
|
||||
cf_socket_close,
|
||||
cf_socket_shutdown,
|
||||
cf_socket_adjust_pollset,
|
||||
Curl_cf_def_data_pending,
|
||||
|
|
@ -1976,7 +1962,6 @@ struct Curl_cftype Curl_cft_unix = {
|
|||
CURL_LOG_LVL_NONE,
|
||||
cf_socket_destroy,
|
||||
cf_tcp_connect,
|
||||
cf_socket_close,
|
||||
cf_socket_shutdown,
|
||||
cf_socket_adjust_pollset,
|
||||
Curl_cf_def_data_pending,
|
||||
|
|
@ -2208,7 +2193,6 @@ struct Curl_cftype Curl_cft_tcp_accept = {
|
|||
CURL_LOG_LVL_NONE,
|
||||
cf_socket_destroy,
|
||||
cf_tcp_accept_connect,
|
||||
cf_socket_close,
|
||||
cf_socket_shutdown,
|
||||
cf_socket_adjust_pollset,
|
||||
Curl_cf_def_data_pending,
|
||||
|
|
|
|||
|
|
@ -33,17 +33,6 @@
|
|||
#include "select.h"
|
||||
#include "curlx/strparse.h"
|
||||
|
||||
#ifdef UNITTESTS
|
||||
/* @unittest 2600 */
|
||||
UNITTEST void cf_def_close(struct Curl_cfilter *cf, struct Curl_easy *data);
|
||||
UNITTEST void cf_def_close(struct Curl_cfilter *cf, struct Curl_easy *data)
|
||||
{
|
||||
cf->connected = FALSE;
|
||||
if(cf->next)
|
||||
cf->next->cft->do_close(cf->next, data);
|
||||
}
|
||||
#endif
|
||||
|
||||
CURLcode Curl_cf_def_shutdown(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data, bool *done)
|
||||
{
|
||||
|
|
@ -169,22 +158,11 @@ void Curl_conn_cf_discard_chain(struct Curl_cfilter **pcf,
|
|||
void Curl_conn_cf_discard_all(struct Curl_easy *data,
|
||||
struct connectdata *conn, int sockindex)
|
||||
{
|
||||
struct curltime *pt = &conn->shutdown.start[sockindex];
|
||||
memset(pt, 0, sizeof(*pt));
|
||||
Curl_conn_cf_discard_chain(&conn->cfilter[sockindex], data);
|
||||
}
|
||||
|
||||
void Curl_conn_close(struct Curl_easy *data, int sockindex)
|
||||
{
|
||||
struct Curl_cfilter *cf;
|
||||
|
||||
DEBUGASSERT(data->conn);
|
||||
/* it is valid to call that without filters being present */
|
||||
cf = data->conn->cfilter[sockindex];
|
||||
if(cf) {
|
||||
cf->cft->do_close(cf, data);
|
||||
}
|
||||
Curl_shutdown_clear(data, sockindex);
|
||||
}
|
||||
|
||||
CURLcode Curl_conn_shutdown(struct Curl_easy *data, int sockindex, bool *done)
|
||||
{
|
||||
struct Curl_cfilter *cf;
|
||||
|
|
@ -426,12 +404,6 @@ CURLcode Curl_conn_cf_connect(struct Curl_cfilter *cf,
|
|||
return CURLE_FAILED_INIT;
|
||||
}
|
||||
|
||||
void Curl_conn_cf_close(struct Curl_cfilter *cf, struct Curl_easy *data)
|
||||
{
|
||||
if(cf)
|
||||
cf->cft->do_close(cf, data);
|
||||
}
|
||||
|
||||
CURLcode Curl_conn_cf_send(struct Curl_cfilter *cf, struct Curl_easy *data,
|
||||
const uint8_t *buf, size_t len, bool eos,
|
||||
size_t *pnwritten)
|
||||
|
|
|
|||
|
|
@ -39,10 +39,6 @@ struct curl_tlssessioninfo;
|
|||
typedef void Curl_cft_destroy_this(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data);
|
||||
|
||||
/* Callback to close the connection immediately. */
|
||||
typedef void Curl_cft_close(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data);
|
||||
|
||||
/* Callback to close the connection filter gracefully, non-blocking.
|
||||
* Implementations MUST NOT chain calls to cf->next.
|
||||
*/
|
||||
|
|
@ -218,7 +214,6 @@ struct Curl_cftype {
|
|||
int log_level; /* log level for such filters */
|
||||
Curl_cft_destroy_this *destroy; /* destroy resources of this cf */
|
||||
Curl_cft_connect *do_connect; /* establish connection */
|
||||
Curl_cft_close *do_close; /* close conn */
|
||||
Curl_cft_shutdown *do_shutdown; /* shutdown conn */
|
||||
Curl_cft_adjust_pollset *adjust_pollset; /* adjust transfer poll set */
|
||||
Curl_cft_data_pending *has_data_pending; /* conn has data pending */
|
||||
|
|
@ -322,7 +317,6 @@ void Curl_conn_cf_discard_all(struct Curl_easy *data,
|
|||
CURLcode Curl_conn_cf_connect(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data,
|
||||
bool *done);
|
||||
void Curl_conn_cf_close(struct Curl_cfilter *cf, struct Curl_easy *data);
|
||||
CURLcode Curl_conn_cf_send(struct Curl_cfilter *cf, struct Curl_easy *data,
|
||||
const uint8_t *buf, size_t len, bool eos,
|
||||
size_t *pnwritten);
|
||||
|
|
@ -433,12 +427,6 @@ unsigned char Curl_conn_get_transport(struct Curl_easy *data,
|
|||
const char *Curl_conn_get_alpn_negotiated(struct Curl_easy *data,
|
||||
struct connectdata *conn);
|
||||
|
||||
/**
|
||||
* Close the filter chain at `sockindex` for connection `data->conn`.
|
||||
* Filters remain in place and may be connected again afterwards.
|
||||
*/
|
||||
void Curl_conn_close(struct Curl_easy *data, int sockindex);
|
||||
|
||||
/**
|
||||
* Shutdown the connection at `sockindex` non-blocking, using timeout
|
||||
* from `data->set.shutdowntimeout`, default DEFAULT_SHUTDOWN_TIMEOUT_MS.
|
||||
|
|
|
|||
|
|
@ -341,6 +341,7 @@ struct cf_setup_ctx {
|
|||
cf_setup_state state;
|
||||
int ssl_mode;
|
||||
uint8_t transport;
|
||||
uint8_t retry_count;
|
||||
};
|
||||
|
||||
#ifndef CURL_DISABLE_PROXY
|
||||
|
|
@ -538,9 +539,9 @@ static CURLcode cf_setup_add_origin_filters(struct Curl_cfilter *cf,
|
|||
return result;
|
||||
}
|
||||
|
||||
static CURLcode cf_setup_connect(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data,
|
||||
bool *done)
|
||||
static CURLcode cf_setup_connect_steps(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data,
|
||||
bool *done)
|
||||
{
|
||||
struct cf_setup_ctx *ctx = cf->ctx;
|
||||
CURLcode result = CURLE_OK;
|
||||
|
|
@ -600,19 +601,32 @@ connect_sub_chain:
|
|||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void cf_setup_close(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data)
|
||||
static CURLcode cf_setup_connect(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data,
|
||||
bool *done)
|
||||
{
|
||||
struct cf_setup_ctx *ctx = cf->ctx;
|
||||
CURLcode result;
|
||||
|
||||
CURL_TRC_CF(data, cf, "close");
|
||||
cf->connected = FALSE;
|
||||
ctx->state = CF_SETUP_INIT;
|
||||
/* In some situations, a server/proxy may close the connection and
|
||||
* we need to connect again (HTTP/1.x proxy auth, for example).
|
||||
* We used to close the filters and reuse them for another attempt,
|
||||
* however that complicates filter code and it is simpler to tear them
|
||||
* all down and start over. */
|
||||
retry:
|
||||
result = cf_setup_connect_steps(cf, data, done);
|
||||
|
||||
if(cf->next) {
|
||||
cf->next->cft->do_close(cf->next, data);
|
||||
if(result == CURLE_AGAIN) {
|
||||
++ctx->retry_count;
|
||||
if(ctx->retry_count > 5) /* arbitrary limit, better just timeout? */
|
||||
return CURLE_COULDNT_CONNECT;
|
||||
|
||||
CURL_TRC_CF(data, cf, "retrying connect, %d. time", ctx->retry_count);
|
||||
Curl_conn_cf_discard_chain(&cf->next, data);
|
||||
ctx->state = CF_SETUP_INIT;
|
||||
goto retry;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static void cf_setup_destroy(struct Curl_cfilter *cf, struct Curl_easy *data)
|
||||
|
|
@ -629,7 +643,6 @@ struct Curl_cftype Curl_cft_setup = {
|
|||
CURL_LOG_LVL_NONE,
|
||||
cf_setup_destroy,
|
||||
cf_setup_connect,
|
||||
cf_setup_close,
|
||||
Curl_cf_def_shutdown,
|
||||
Curl_cf_def_adjust_pollset,
|
||||
Curl_cf_def_data_pending,
|
||||
|
|
|
|||
|
|
@ -150,8 +150,8 @@ void Curl_cshutdn_terminate(struct Curl_easy *data,
|
|||
CURL_TRC_M(admin, "[SHUTDOWN] %sclosing connection #%" FMT_OFF_T,
|
||||
conn->bits.shutdown_filters ? "" : "force ",
|
||||
conn->connection_id);
|
||||
Curl_conn_close(admin, SECONDARYSOCKET);
|
||||
Curl_conn_close(admin, FIRSTSOCKET);
|
||||
Curl_conn_cf_discard_all(admin, conn, SECONDARYSOCKET);
|
||||
Curl_conn_cf_discard_all(admin, conn, FIRSTSOCKET);
|
||||
Curl_detach_connection(admin);
|
||||
|
||||
if(data->multi)
|
||||
|
|
|
|||
|
|
@ -355,7 +355,6 @@ static void close_secondarysocket(struct Curl_easy *data,
|
|||
{
|
||||
(void)ftpc;
|
||||
CURL_TRC_FTP(data, "[%s] closing DATA connection", FTP_CSTATE(ftpc));
|
||||
Curl_conn_close(data, SECONDARYSOCKET);
|
||||
Curl_conn_cf_discard_all(data, data->conn, SECONDARYSOCKET);
|
||||
}
|
||||
|
||||
|
|
|
|||
27
lib/http2.c
27
lib/http2.c
|
|
@ -189,6 +189,8 @@ static void cf_h2_ctx_init(struct cf_h2_ctx *ctx, bool via_h1_upgrade)
|
|||
static void cf_h2_ctx_free(struct cf_h2_ctx *ctx)
|
||||
{
|
||||
if(ctx && ctx->initialized) {
|
||||
if(ctx->h2)
|
||||
nghttp2_session_del(ctx->h2);
|
||||
Curl_bufq_free(&ctx->inbufq);
|
||||
Curl_bufq_free(&ctx->outbufq);
|
||||
Curl_bufcp_free(&ctx->stream_bufcp);
|
||||
|
|
@ -199,14 +201,6 @@ static void cf_h2_ctx_free(struct cf_h2_ctx *ctx)
|
|||
curlx_free(ctx);
|
||||
}
|
||||
|
||||
static void cf_h2_ctx_close(struct cf_h2_ctx *ctx)
|
||||
{
|
||||
if(ctx->h2) {
|
||||
nghttp2_session_del(ctx->h2);
|
||||
ctx->h2 = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t cf_h2_initial_win_size(struct Curl_easy *data)
|
||||
{
|
||||
#if NGHTTP2_HAS_SET_LOCAL_WINDOW_SIZE
|
||||
|
|
@ -2550,22 +2544,6 @@ out:
|
|||
return result;
|
||||
}
|
||||
|
||||
static void cf_h2_close(struct Curl_cfilter *cf, struct Curl_easy *data)
|
||||
{
|
||||
struct cf_h2_ctx *ctx = cf->ctx;
|
||||
|
||||
if(ctx) {
|
||||
struct cf_call_data save;
|
||||
|
||||
CF_DATA_SAVE(save, cf, data);
|
||||
cf_h2_ctx_close(ctx);
|
||||
CF_DATA_RESTORE(cf, save);
|
||||
cf->connected = FALSE;
|
||||
}
|
||||
if(cf->next)
|
||||
cf->next->cft->do_close(cf->next, data);
|
||||
}
|
||||
|
||||
static void cf_h2_destroy(struct Curl_cfilter *cf, struct Curl_easy *data)
|
||||
{
|
||||
struct cf_h2_ctx *ctx = cf->ctx;
|
||||
|
|
@ -2788,7 +2766,6 @@ struct Curl_cftype Curl_cft_nghttp2 = {
|
|||
CURL_LOG_LVL_NONE,
|
||||
cf_h2_destroy,
|
||||
cf_h2_connect,
|
||||
cf_h2_close,
|
||||
cf_h2_shutdown,
|
||||
cf_h2_adjust_pollset,
|
||||
cf_h2_data_pending,
|
||||
|
|
|
|||
|
|
@ -709,22 +709,12 @@ static void http_proxy_cf_destroy(struct Curl_cfilter *cf,
|
|||
}
|
||||
}
|
||||
|
||||
static void http_proxy_cf_close(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data)
|
||||
{
|
||||
CURL_TRC_CF(data, cf, "close");
|
||||
cf->connected = FALSE;
|
||||
if(cf->next)
|
||||
cf->next->cft->do_close(cf->next, data);
|
||||
}
|
||||
|
||||
struct Curl_cftype Curl_cft_http_proxy = {
|
||||
"HTTP-PROXY",
|
||||
CF_TYPE_IP_CONNECT | CF_TYPE_PROXY | CF_TYPE_SETUP,
|
||||
0,
|
||||
http_proxy_cf_destroy,
|
||||
http_proxy_cf_connect,
|
||||
http_proxy_cf_close,
|
||||
Curl_cf_def_shutdown,
|
||||
Curl_cf_def_adjust_pollset,
|
||||
Curl_cf_def_data_pending,
|
||||
|
|
|
|||
|
|
@ -1289,14 +1289,6 @@ static CURLcode socks_cf_adjust_pollset(struct Curl_cfilter *cf,
|
|||
return result;
|
||||
}
|
||||
|
||||
static void socks_proxy_cf_close(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data)
|
||||
{
|
||||
cf->connected = FALSE;
|
||||
if(cf->next)
|
||||
cf->next->cft->do_close(cf->next, data);
|
||||
}
|
||||
|
||||
static void socks_proxy_cf_destroy(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data)
|
||||
{
|
||||
|
|
@ -1339,7 +1331,6 @@ struct Curl_cftype Curl_cft_socks_proxy = {
|
|||
0,
|
||||
socks_proxy_cf_destroy,
|
||||
socks_proxy_cf_connect,
|
||||
socks_proxy_cf_close,
|
||||
Curl_cf_def_shutdown,
|
||||
socks_cf_adjust_pollset,
|
||||
Curl_cf_def_data_pending,
|
||||
|
|
|
|||
|
|
@ -2389,26 +2389,19 @@ static void cf_ngtcp2_conn_close(struct Curl_cfilter *cf,
|
|||
cf_ngtcp2_shutdown(cf, data, &done);
|
||||
}
|
||||
|
||||
static void cf_ngtcp2_close(struct Curl_cfilter *cf, struct Curl_easy *data)
|
||||
{
|
||||
struct cf_ngtcp2_ctx *ctx = cf->ctx;
|
||||
struct cf_call_data save;
|
||||
|
||||
CF_DATA_SAVE(save, cf, data);
|
||||
if(ctx && ctx->qconn) {
|
||||
cf_ngtcp2_conn_close(cf, data);
|
||||
cf_ngtcp2_ctx_close(ctx);
|
||||
CURL_TRC_CF(data, cf, "close");
|
||||
}
|
||||
cf->connected = FALSE;
|
||||
CF_DATA_RESTORE(cf, save);
|
||||
}
|
||||
|
||||
static void cf_ngtcp2_destroy(struct Curl_cfilter *cf, struct Curl_easy *data)
|
||||
{
|
||||
struct cf_ngtcp2_ctx *ctx = cf->ctx;
|
||||
|
||||
CURL_TRC_CF(data, cf, "destroy");
|
||||
if(cf->ctx) {
|
||||
cf_ngtcp2_close(cf, data);
|
||||
if(ctx) {
|
||||
if(ctx->qconn) {
|
||||
struct cf_call_data save;
|
||||
CF_DATA_SAVE(save, cf, data);
|
||||
cf_ngtcp2_conn_close(cf, data);
|
||||
cf_ngtcp2_ctx_close(ctx);
|
||||
CF_DATA_RESTORE(cf, save);
|
||||
}
|
||||
cf_ngtcp2_ctx_free(cf->ctx);
|
||||
cf->ctx = NULL;
|
||||
}
|
||||
|
|
@ -3087,7 +3080,6 @@ struct Curl_cftype Curl_cft_http3 = {
|
|||
0,
|
||||
cf_ngtcp2_destroy,
|
||||
cf_ngtcp2_connect,
|
||||
cf_ngtcp2_close,
|
||||
cf_ngtcp2_shutdown,
|
||||
cf_ngtcp2_adjust_pollset,
|
||||
Curl_cf_def_data_pending,
|
||||
|
|
|
|||
|
|
@ -1499,16 +1499,6 @@ out:
|
|||
return result;
|
||||
}
|
||||
|
||||
static void cf_quiche_close(struct Curl_cfilter *cf, struct Curl_easy *data)
|
||||
{
|
||||
if(cf->ctx) {
|
||||
bool done;
|
||||
(void)cf_quiche_shutdown(cf, data, &done);
|
||||
cf_quiche_ctx_close(cf->ctx);
|
||||
cf->connected = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static void cf_quiche_destroy(struct Curl_cfilter *cf, struct Curl_easy *data)
|
||||
{
|
||||
(void)data;
|
||||
|
|
@ -1626,7 +1616,6 @@ struct Curl_cftype Curl_cft_http3 = {
|
|||
0,
|
||||
cf_quiche_destroy,
|
||||
cf_quiche_connect,
|
||||
cf_quiche_close,
|
||||
cf_quiche_shutdown,
|
||||
cf_quiche_adjust_pollset,
|
||||
Curl_cf_def_data_pending,
|
||||
|
|
|
|||
|
|
@ -978,18 +978,6 @@ static void ssl_cf_destroy(struct Curl_cfilter *cf, struct Curl_easy *data)
|
|||
cf->ctx = NULL;
|
||||
}
|
||||
|
||||
static void ssl_cf_close(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data)
|
||||
{
|
||||
struct cf_call_data save;
|
||||
|
||||
CF_DATA_SAVE(save, cf, data);
|
||||
cf_close(cf, data);
|
||||
if(cf->next)
|
||||
cf->next->cft->do_close(cf->next, data);
|
||||
CF_DATA_RESTORE(cf, save);
|
||||
}
|
||||
|
||||
static CURLcode ssl_cf_connect(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data,
|
||||
bool *done)
|
||||
|
|
@ -1351,7 +1339,6 @@ struct Curl_cftype Curl_cft_ssl = {
|
|||
CURL_LOG_LVL_NONE,
|
||||
ssl_cf_destroy,
|
||||
ssl_cf_connect,
|
||||
ssl_cf_close,
|
||||
ssl_cf_shutdown,
|
||||
ssl_cf_adjust_pollset,
|
||||
ssl_cf_data_pending,
|
||||
|
|
@ -1371,7 +1358,6 @@ struct Curl_cftype Curl_cft_ssl_proxy = {
|
|||
CURL_LOG_LVL_NONE,
|
||||
ssl_cf_destroy,
|
||||
ssl_cf_connect,
|
||||
ssl_cf_close,
|
||||
ssl_cf_shutdown,
|
||||
ssl_cf_adjust_pollset,
|
||||
ssl_cf_data_pending,
|
||||
|
|
|
|||
|
|
@ -177,7 +177,6 @@ static CURLcode cf_test_create(struct Curl_cfilter **pcf,
|
|||
CURL_LOG_LVL_NONE,
|
||||
cf_test_destroy,
|
||||
cf_test_connect,
|
||||
cf_def_close,
|
||||
Curl_cf_def_shutdown,
|
||||
cf_test_adjust_pollset,
|
||||
Curl_cf_def_data_pending,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue