url: reduce conn->data references

... there are a few left but let's keep them to last

Closes #6512
This commit is contained in:
Daniel Stenberg 2021-01-24 23:32:24 +01:00
parent df58343440
commit 560fc170ec
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
4 changed files with 47 additions and 45 deletions

View File

@ -1108,7 +1108,7 @@ CURLcode Curl_once_resolved(struct Curl_easy *data, bool *protocol_done)
data->state.async.dns = NULL;
}
result = Curl_setup_conn(conn, protocol_done);
result = Curl_setup_conn(data, protocol_done);
if(result) {
Curl_detach_connnection(data);

View File

@ -107,7 +107,7 @@ static CURLcode smtp_setup_connection(struct Curl_easy *data,
static CURLcode smtp_parse_url_options(struct connectdata *conn);
static CURLcode smtp_parse_url_path(struct Curl_easy *data);
static CURLcode smtp_parse_custom_request(struct Curl_easy *data);
static CURLcode smtp_parse_address(struct connectdata *conn, const char *fqma,
static CURLcode smtp_parse_address(struct Curl_easy *data, const char *fqma,
char **address, struct hostname *host);
static CURLcode smtp_perform_auth(struct Curl_easy *data,
struct connectdata *conn, const char *mech,
@ -515,7 +515,7 @@ static CURLcode smtp_perform_command(struct Curl_easy *data)
/* Parse the mailbox to verify into the local address and host name
parts, converting the host name to an IDN A-label if necessary */
result = smtp_parse_address(conn, smtp->rcpt->data,
result = smtp_parse_address(data, smtp->rcpt->data,
&address, &host);
if(result)
return result;
@ -589,7 +589,7 @@ static CURLcode smtp_perform_mail(struct Curl_easy *data)
/* Parse the FROM mailbox into the local address and host name parts,
converting the host name to an IDN A-label if necessary */
result = smtp_parse_address(conn, data->set.str[STRING_MAIL_FROM],
result = smtp_parse_address(data, data->set.str[STRING_MAIL_FROM],
&address, &host);
if(result)
return result;
@ -627,7 +627,7 @@ static CURLcode smtp_perform_mail(struct Curl_easy *data)
/* Parse the AUTH mailbox into the local address and host name parts,
converting the host name to an IDN A-label if necessary */
result = smtp_parse_address(conn, data->set.str[STRING_MAIL_AUTH],
result = smtp_parse_address(data, data->set.str[STRING_MAIL_AUTH],
&address, &host);
if(result) {
free(from);
@ -764,7 +764,7 @@ static CURLcode smtp_perform_rcpt_to(struct Curl_easy *data)
/* Parse the recipient mailbox into the local address and host name parts,
converting the host name to an IDN A-label if necessary */
result = smtp_parse_address(conn, smtp->rcpt->data,
result = smtp_parse_address(data, smtp->rcpt->data,
&address, &host);
if(result)
return result;
@ -1757,7 +1757,7 @@ static CURLcode smtp_parse_custom_request(struct Curl_easy *data)
* calling function deems it to be) then the input will simply be returned in
* the address part with the host name being NULL.
*/
static CURLcode smtp_parse_address(struct connectdata *conn, const char *fqma,
static CURLcode smtp_parse_address(struct Curl_easy *data, const char *fqma,
char **address, struct hostname *host)
{
CURLcode result = CURLE_OK;
@ -1782,7 +1782,7 @@ static CURLcode smtp_parse_address(struct connectdata *conn, const char *fqma,
host->name = host->name + 1;
/* Attempt to convert the host name to IDN ACE */
(void) Curl_idnconvert_hostname(conn, host);
(void) Curl_idnconvert_hostname(data, host);
/* If Curl_idnconvert_hostname() fails then we shall attempt to continue
and send the host name using UTF-8 rather than as 7-bit ACE (which is

View File

@ -946,15 +946,13 @@ static bool conn_maxage(struct Curl_easy *data,
struct connectdata *conn,
struct curltime now)
{
if(!conn->data) {
timediff_t idletime = Curl_timediff(now, conn->lastused);
idletime /= 1000; /* integer seconds is fine */
timediff_t idletime = Curl_timediff(now, conn->lastused);
idletime /= 1000; /* integer seconds is fine */
if(idletime > data->set.maxage_conn) {
infof(data, "Too old connection (%ld seconds), disconnect it\n",
idletime);
return TRUE;
}
if(idletime > data->set.maxage_conn) {
infof(data, "Too old connection (%ld seconds), disconnect it\n",
idletime);
return TRUE;
}
return FALSE;
}
@ -1486,7 +1484,7 @@ void Curl_verboseconnect(struct Curl_easy *data,
struct connectdata *conn)
{
if(data->set.verbose)
infof(conn->data, "Connected to %s (%s) port %ld (#%ld)\n",
infof(data, "Connected to %s (%s) port %ld (#%ld)\n",
#ifndef CURL_DISABLE_PROXY
conn->bits.socksproxy ? conn->socks_proxy.host.dispname :
conn->bits.httpproxy ? conn->http_proxy.host.dispname :
@ -1532,16 +1530,14 @@ static void strip_trailing_dot(struct hostname *host)
/*
* Perform any necessary IDN conversion of hostname
*/
CURLcode Curl_idnconvert_hostname(struct connectdata *conn,
CURLcode Curl_idnconvert_hostname(struct Curl_easy *data,
struct hostname *host)
{
struct Curl_easy *data = conn->data;
#ifndef USE_LIBIDN2
(void)data;
(void)conn;
(void)data;
#elif defined(CURL_DISABLE_VERBOSE_STRINGS)
(void)conn;
(void)data;
#endif
/* set the name we use to display the host name */
@ -1836,12 +1832,14 @@ CURLcode Curl_uc_to_curlcode(CURLUcode uc)
* the scope_id based on that!
*/
static void zonefrom_url(CURLU *uh, struct connectdata *conn)
static void zonefrom_url(CURLU *uh, struct Curl_easy *data,
struct connectdata *conn)
{
char *zoneid;
CURLUcode uc;
uc = curl_url_get(uh, CURLUPART_ZONEID, &zoneid, 0);
CURLUcode uc = curl_url_get(uh, CURLUPART_ZONEID, &zoneid, 0);
#ifdef CURL_DISABLE_VERBOSE_STRINGS
(void)data;
#endif
if(!uc && zoneid) {
char *endp;
@ -1864,7 +1862,7 @@ static void zonefrom_url(CURLU *uh, struct connectdata *conn)
scopeidx = if_nametoindex(zoneid);
#endif
if(!scopeidx)
infof(conn->data, "Invalid zoneid: %s; %s\n", zoneid,
infof(data, "Invalid zoneid: %s; %s\n", zoneid,
strerror(errno));
else
conn->scope_id = scopeidx;
@ -2046,7 +2044,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
hlen = strlen(hostname);
hostname[hlen - 1] = 0;
zonefrom_url(uh, conn);
zonefrom_url(uh, data, conn);
}
/* make sure the connect struct gets its own copy of the host name */
@ -2234,7 +2232,8 @@ static bool check_noproxy(const char *name, const char *no_proxy)
* name and is not limited to HTTP proxies only.
* The returned pointer must be freed by the caller (unless NULL)
****************************************************************/
static char *detect_proxy(struct connectdata *conn)
static char *detect_proxy(struct Curl_easy *data,
struct connectdata *conn)
{
char *proxy = NULL;
@ -2259,6 +2258,9 @@ static char *detect_proxy(struct connectdata *conn)
const char *protop = conn->handler->scheme;
char *envp = proxy_env;
char *prox;
#ifdef CURL_DISABLE_VERBOSE_STRINGS
(void)data;
#endif
/* Now, build <protocol>_proxy and check for such a one to use */
while(*protop)
@ -2301,7 +2303,7 @@ static char *detect_proxy(struct connectdata *conn)
}
}
if(proxy)
infof(conn->data, "Uses proxy env variable %s == '%s'\n", envp, proxy);
infof(data, "Uses proxy env variable %s == '%s'\n", envp, proxy);
return proxy;
}
@ -2440,7 +2442,7 @@ static CURLcode parse_proxy(struct Curl_easy *data,
size_t len = strlen(host);
host[len-1] = 0; /* clear the trailing bracket */
host++;
zonefrom_url(uhp, conn);
zonefrom_url(uhp, data, conn);
}
proxyinfo->host.name = host;
@ -2473,13 +2475,13 @@ static CURLcode parse_proxy_auth(struct Curl_easy *data,
/* create_conn helper to parse and init proxy values. to be called after unix
socket init but before any proxy vars are evaluated. */
static CURLcode create_conn_helper_init_proxy(struct connectdata *conn)
static CURLcode create_conn_helper_init_proxy(struct Curl_easy *data,
struct connectdata *conn)
{
char *proxy = NULL;
char *socksproxy = NULL;
char *no_proxy = NULL;
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
/*************************************************************
* Extract the user and password from the authentication string
@ -2521,7 +2523,7 @@ static CURLcode create_conn_helper_init_proxy(struct connectdata *conn)
no_proxy = curl_getenv(p);
}
if(no_proxy) {
infof(conn->data, "Uses proxy env variable %s == '%s'\n", p, no_proxy);
infof(data, "Uses proxy env variable %s == '%s'\n", p, no_proxy);
}
}
@ -2533,7 +2535,7 @@ static CURLcode create_conn_helper_init_proxy(struct connectdata *conn)
#ifndef CURL_DISABLE_HTTP
else if(!proxy && !socksproxy)
/* if the host is not in the noproxy list, detect proxy. */
proxy = detect_proxy(conn);
proxy = detect_proxy(data, conn);
#endif /* CURL_DISABLE_HTTP */
Curl_safefree(no_proxy);
@ -3531,7 +3533,7 @@ static CURLcode create_conn(struct Curl_easy *data,
/* After the unix socket init but before the proxy vars are used, parse and
initialize the proxy vars */
#ifndef CURL_DISABLE_PROXY
result = create_conn_helper_init_proxy(conn);
result = create_conn_helper_init_proxy(data, conn);
if(result)
goto out;
@ -3572,22 +3574,22 @@ static CURLcode create_conn(struct Curl_easy *data,
/*************************************************************
* IDN-convert the hostnames
*************************************************************/
result = Curl_idnconvert_hostname(conn, &conn->host);
result = Curl_idnconvert_hostname(data, &conn->host);
if(result)
goto out;
if(conn->bits.conn_to_host) {
result = Curl_idnconvert_hostname(conn, &conn->conn_to_host);
result = Curl_idnconvert_hostname(data, &conn->conn_to_host);
if(result)
goto out;
}
#ifndef CURL_DISABLE_PROXY
if(conn->bits.httpproxy) {
result = Curl_idnconvert_hostname(conn, &conn->http_proxy.host);
result = Curl_idnconvert_hostname(data, &conn->http_proxy.host);
if(result)
goto out;
}
if(conn->bits.socksproxy) {
result = Curl_idnconvert_hostname(conn, &conn->socks_proxy.host);
result = Curl_idnconvert_hostname(data, &conn->socks_proxy.host);
if(result)
goto out;
}
@ -3948,11 +3950,11 @@ out:
* conn->data MUST already have been setup fine (in create_conn)
*/
CURLcode Curl_setup_conn(struct connectdata *conn,
CURLcode Curl_setup_conn(struct Curl_easy *data,
bool *protocol_done)
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
struct connectdata *conn = data->conn;
Curl_pgrsTime(data, TIMER_NAMELOOKUP);
@ -4026,7 +4028,7 @@ CURLcode Curl_connect(struct Curl_easy *data,
/* DNS resolution is done: that's either because this is a reused
connection, in which case DNS was unnecessary, or because DNS
really did finish already (synch resolver/fast async resolve) */
result = Curl_setup_conn(conn, protocol_done);
result = Curl_setup_conn(data, protocol_done);
}
}

View File

@ -37,7 +37,7 @@ CURLcode Curl_close(struct Curl_easy **datap); /* opposite of curl_open() */
CURLcode Curl_connect(struct Curl_easy *, bool *async, bool *protocol_connect);
CURLcode Curl_disconnect(struct Curl_easy *data,
struct connectdata *, bool dead_connection);
CURLcode Curl_setup_conn(struct connectdata *conn,
CURLcode Curl_setup_conn(struct Curl_easy *data,
bool *protocol_done);
void Curl_free_request_state(struct Curl_easy *data);
CURLcode Curl_parse_login_details(const char *login, const size_t len,
@ -47,7 +47,7 @@ CURLcode Curl_parse_login_details(const char *login, const size_t len,
const struct Curl_handler *Curl_builtin_scheme(const char *scheme);
bool Curl_is_ASCII_name(const char *hostname);
CURLcode Curl_idnconvert_hostname(struct connectdata *conn,
CURLcode Curl_idnconvert_hostname(struct Curl_easy *data,
struct hostname *host);
void Curl_free_idnconverted_hostname(struct hostname *host);