mirror of
https://github.com/curl/curl.git
synced 2026-08-24 11:43:38 +03:00
urldata: rename easy_conn to just conn
We use "conn" everywhere to be a pointer to the connection. Introduces two functions that "attaches" and "detaches" the connection to and from the transfer. Going forward, we should favour using "data->conn" (since a transfer always only has a single connection or none at all) to "conn->data" (since a connection can have none, one or many transfers associated with it and updating conn->data to be correct is error prone and a frequent reason for internal issues). Closes #3442
This commit is contained in:
parent
61faa0b420
commit
ba243235ec
15 changed files with 199 additions and 204 deletions
17
lib/url.c
17
lib/url.c
|
|
@ -3607,6 +3607,7 @@ static CURLcode create_conn(struct Curl_easy *data,
|
|||
size_t max_total_connections = Curl_multi_max_total_connections(data->multi);
|
||||
|
||||
*async = FALSE;
|
||||
*in_connect = NULL;
|
||||
|
||||
/*************************************************************
|
||||
* Check input data
|
||||
|
|
@ -4134,11 +4135,11 @@ CURLcode Curl_setup_conn(struct connectdata *conn,
|
|||
}
|
||||
|
||||
CURLcode Curl_connect(struct Curl_easy *data,
|
||||
struct connectdata **in_connect,
|
||||
bool *asyncp,
|
||||
bool *protocol_done)
|
||||
{
|
||||
CURLcode result;
|
||||
struct connectdata *conn;
|
||||
|
||||
*asyncp = FALSE; /* assume synchronous resolves by default */
|
||||
|
||||
|
|
@ -4148,30 +4149,30 @@ CURLcode Curl_connect(struct Curl_easy *data,
|
|||
data->req.maxdownload = -1;
|
||||
|
||||
/* call the stuff that needs to be called */
|
||||
result = create_conn(data, in_connect, asyncp);
|
||||
result = create_conn(data, &conn, asyncp);
|
||||
|
||||
if(!result) {
|
||||
if(CONN_INUSE(*in_connect))
|
||||
if(CONN_INUSE(conn))
|
||||
/* pipelining */
|
||||
*protocol_done = TRUE;
|
||||
else if(!*asyncp) {
|
||||
/* 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(*in_connect, protocol_done);
|
||||
result = Curl_setup_conn(conn, protocol_done);
|
||||
}
|
||||
}
|
||||
|
||||
if(result == CURLE_NO_CONNECTION_AVAILABLE) {
|
||||
*in_connect = NULL;
|
||||
return result;
|
||||
}
|
||||
else if(result && *in_connect) {
|
||||
else if(result && conn) {
|
||||
/* We're not allowed to return failure with memory left allocated in the
|
||||
connectdata struct, free those here */
|
||||
Curl_disconnect(data, *in_connect, TRUE);
|
||||
*in_connect = NULL; /* return a NULL */
|
||||
Curl_disconnect(data, conn, TRUE);
|
||||
}
|
||||
else
|
||||
Curl_attach_connnection(data, conn);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue