summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2021-01-25 09:16:33 +0100
committerDaniel Stenberg <daniel@haxx.se>2021-01-25 09:16:33 +0100
commitd5debba08df7bf9e87270fab3954a4a388e78237 (patch)
treeda5f41f98cbb5176e9c766a5c0ab809e95731892
parentdd330521eb65b9cb5f74748dbbe3ee54061e7785 (diff)
downloadcurl-bagder/final-conn-data.tar.gz
lib: remove "Curl_easy *data" from connectdatabagder/final-conn-data
-rw-r--r--lib/conncache.c2
-rw-r--r--lib/connect.c1
-rw-r--r--lib/easy.c12
-rw-r--r--lib/http2.c10
-rw-r--r--lib/multi.c54
-rw-r--r--lib/openldap.c15
-rw-r--r--lib/url.c21
-rw-r--r--lib/urldata.h4
-rw-r--r--lib/vtls/openssl.c9
9 files changed, 25 insertions, 103 deletions
diff --git a/lib/conncache.c b/lib/conncache.c
index 8dfdc0ac8..5453c00f3 100644
--- a/lib/conncache.c
+++ b/lib/conncache.c
@@ -466,7 +466,6 @@ Curl_conncache_extract_bundle(struct Curl_easy *data,
data->state.conn_cache->num_conn--;
DEBUGF(infof(data, "The cache now contains %zu members\n",
data->state.conn_cache->num_conn));
- conn_candidate->data = data; /* associate! */
}
return conn_candidate;
@@ -529,7 +528,6 @@ Curl_conncache_extract_oldest(struct Curl_easy *data)
connc->num_conn--;
DEBUGF(infof(data, "The cache now contains %zu members\n",
connc->num_conn));
- conn_candidate->data = data; /* associate! */
}
CONNCACHE_UNLOCK(data);
diff --git a/lib/connect.c b/lib/connect.c
index 052542449..6f4e601cc 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -1440,7 +1440,6 @@ curl_socket_t Curl_getconnectinfo(struct Curl_easy *data,
if(connp) {
/* only store this if the caller cares for it */
*connp = c;
- c->data = data;
}
return c->sock[FIRSTSOCKET];
}
diff --git a/lib/easy.c b/lib/easy.c
index 0fb255af4..fd4123bed 100644
--- a/lib/easy.c
+++ b/lib/easy.c
@@ -1052,8 +1052,6 @@ CURLcode curl_easy_pause(struct Curl_easy *data, int action)
unsigned int i;
unsigned int count = data->state.tempcount;
struct tempbuf writebuf[3]; /* there can only be three */
- struct connectdata *conn = data->conn;
- struct Curl_easy *saved_data = NULL;
/* copy the structs to allow for immediate re-pausing */
for(i = 0; i < data->state.tempcount; i++) {
@@ -1062,12 +1060,6 @@ CURLcode curl_easy_pause(struct Curl_easy *data, int action)
}
data->state.tempcount = 0;
- /* set the connection's current owner */
- if(conn->data != data) {
- saved_data = conn->data;
- conn->data = data;
- }
-
for(i = 0; i < count; i++) {
/* even if one function returns error, this loops through and frees
all buffers */
@@ -1078,10 +1070,6 @@ CURLcode curl_easy_pause(struct Curl_easy *data, int action)
Curl_dyn_free(&writebuf[i].b);
}
- /* recover previous owner of the connection */
- if(saved_data)
- conn->data = saved_data;
-
if(result)
return result;
}
diff --git a/lib/http2.c b/lib/http2.c
index a7aa51fe5..9e1ff5aaf 100644
--- a/lib/http2.c
+++ b/lib/http2.c
@@ -736,14 +736,10 @@ static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame,
stream->memlen += ncopy;
drain_this(data_s, httpc);
- {
- /* get the pointer from userp again since it was re-assigned above */
- struct connectdata *conn_s = (struct connectdata *)userp;
- /* if we receive data for another handle, wake that up */
- if(conn_s->data != data_s)
- Curl_expire(data_s, 0, EXPIRE_RUN_NOW);
- }
+ /* if we receive data for another handle, wake that up */
+ if(data != data_s)
+ Curl_expire(data_s, 0, EXPIRE_RUN_NOW);
break;
case NGHTTP2_PUSH_PROMISE:
rv = push_promise(data_s, conn, &frame->push_promise);
diff --git a/lib/multi.c b/lib/multi.c
index 85707a1af..9e87fc921 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -562,8 +562,6 @@ static CURLcode multi_done(struct Curl_easy *data,
/* Stop if multi_done() has already been called */
return CURLE_OK;
- conn->data = data; /* ensure the connection uses this transfer now */
-
/* Stop the resolver and free its own resources (but not dns_entry yet). */
Curl_resolver_kill(data);
@@ -604,16 +602,12 @@ static CURLcode multi_done(struct Curl_easy *data,
Curl_detach_connnection(data);
if(CONN_INUSE(conn)) {
/* Stop if still used. */
- /* conn->data must not remain pointing to this transfer since it is going
- away! Find another to own it! */
- conn->data = conn->easyq.head->ptr;
CONNCACHE_UNLOCK(data);
DEBUGF(infof(data, "Connection still in use %zu, "
"no more multi_done now!\n",
conn->easyq.size));
return CURLE_OK;
}
- conn->data = NULL; /* the connection now has no owner */
data->state.done = TRUE; /* called just now! */
if(conn->dns_entry) {
@@ -718,7 +712,6 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
{
struct Curl_easy *easy = data;
bool premature;
- bool easy_owns_conn;
struct Curl_llist_element *e;
/* First, make some basic checks that the CURLM handle is a good handle */
@@ -741,8 +734,6 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
return CURLM_RECURSIVE_API_CALL;
premature = (data->mstate < CURLM_STATE_COMPLETED) ? TRUE : FALSE;
- easy_owns_conn = (data->conn && (data->conn->data == easy)) ?
- TRUE : FALSE;
/* If the 'state' is not INIT or COMPLETED, we might need to do something
nice to put the easy_handle in a good known state when this returns. */
@@ -752,30 +743,13 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
multi->num_alive--;
}
- if(data->conn &&
- data->mstate > CURLM_STATE_DO &&
- data->mstate < CURLM_STATE_COMPLETED) {
- /* Set connection owner so that the DONE function closes it. We can
- safely do this here since connection is killed. */
- data->conn->data = easy;
- streamclose(data->conn, "Removed with partial response");
- easy_owns_conn = TRUE;
- }
-
- if(data->conn) {
+ if(data->conn)
+ /* multi_done() clears the association between the easy handle and the
+ connection.
- /* we must call multi_done() here (if we still own the connection) so that
- we don't leave a half-baked one around */
- if(easy_owns_conn) {
-
- /* multi_done() clears the association between the easy handle and the
- connection.
-
- Note that this ignores the return code simply because there's
- nothing really useful to do with it anyway! */
- (void)multi_done(data, data->result, premature);
- }
- }
+ Note that this ignores the return code simply because there's
+ nothing really useful to do with it anyway! */
+ (void)multi_done(data, data->result, premature);
/* The timer must be shut down before data->multi is set to NULL, else the
timenode will remain in the splay tree after curl_easy_cleanup is
@@ -984,12 +958,6 @@ static int multi_getsock(struct Curl_easy *data,
if(!conn)
return 0;
- if(data->mstate > CURLM_STATE_CONNECT &&
- data->mstate < CURLM_STATE_COMPLETED) {
- /* Set up ownership correctly */
- data->conn->data = data;
- }
-
switch(data->mstate) {
default:
return 0;
@@ -1397,7 +1365,6 @@ static CURLcode multi_do(struct Curl_easy *data, bool *done)
DEBUGASSERT(conn);
DEBUGASSERT(conn->handler);
- DEBUGASSERT(conn->data == data);
if(conn->handler->do_it)
/* generic protocol-specific function pointer set in curl_connect() */
@@ -1578,15 +1545,6 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
process_pending_handles(multi); /* multiplexed */
}
- if(data->mstate > CURLM_STATE_CONNECT &&
- data->mstate < CURLM_STATE_COMPLETED) {
- /* Make sure we set the connection's current owner */
- DEBUGASSERT(data->conn);
- if(!data->conn)
- return CURLM_INTERNAL_ERROR;
- data->conn->data = data;
- }
-
if(data->conn &&
(data->mstate >= CURLM_STATE_CONNECT) &&
(data->mstate < CURLM_STATE_COMPLETED)) {
diff --git a/lib/openldap.c b/lib/openldap.c
index 4070bbf88..77b7145ee 100644
--- a/lib/openldap.c
+++ b/lib/openldap.c
@@ -278,7 +278,7 @@ static CURLcode ldap_connecting(struct Curl_easy *data, bool *done)
if(!li->sslinst) {
Sockbuf *sb;
ldap_get_option(li->ld, LDAP_OPT_SOCKBUF, &sb);
- ber_sockbuf_add_io(sb, &ldapsb_tls, LBER_SBIOD_LEVEL_TRANSPORT, conn);
+ ber_sockbuf_add_io(sb, &ldapsb_tls, LBER_SBIOD_LEVEL_TRANSPORT, data);
li->sslinst = TRUE;
li->recv = conn->recv[FIRSTSOCKET];
li->send = conn->send[FIRSTSOCKET];
@@ -716,7 +716,8 @@ ldapsb_tls_ctrl(Sockbuf_IO_Desc *sbiod, int opt, void *arg)
{
(void)arg;
if(opt == LBER_SB_OPT_DATA_READY) {
- struct connectdata *conn = sbiod->sbiod_pvt;
+ struct Curl_easy *data = sbiod->sbiod_pvt;
+ struct connectdata *conn = data->conn;
return Curl_ssl_data_pending(conn, FIRSTSOCKET);
}
return 0;
@@ -725,12 +726,13 @@ ldapsb_tls_ctrl(Sockbuf_IO_Desc *sbiod, int opt, void *arg)
static ber_slen_t
ldapsb_tls_read(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len)
{
- struct connectdata *conn = sbiod->sbiod_pvt;
+ struct Curl_easy *data = sbiod->sbiod_pvt;
+ struct connectdata *conn = data->conn;
struct ldapconninfo *li = conn->proto.ldapc;
ber_slen_t ret;
CURLcode err = CURLE_RECV_ERROR;
- ret = (li->recv)(conn->data, FIRSTSOCKET, buf, len, &err);
+ ret = (li->recv)(data, FIRSTSOCKET, buf, len, &err);
if(ret < 0 && err == CURLE_AGAIN) {
SET_SOCKERRNO(EWOULDBLOCK);
}
@@ -740,12 +742,13 @@ ldapsb_tls_read(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len)
static ber_slen_t
ldapsb_tls_write(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len)
{
- struct connectdata *conn = sbiod->sbiod_pvt;
+ struct Curl_easy *data = sbiod->sbiod_pvt;
+ struct connectdata *conn = data->conn;
struct ldapconninfo *li = conn->proto.ldapc;
ber_slen_t ret;
CURLcode err = CURLE_SEND_ERROR;
- ret = (li->send)(conn->data, FIRSTSOCKET, buf, len, &err);
+ ret = (li->send)(data, FIRSTSOCKET, buf, len, &err);
if(ret < 0 && err == CURLE_AGAIN) {
SET_SOCKERRNO(EWOULDBLOCK);
}
diff --git a/lib/url.c b/lib/url.c
index 4a3e50fdd..4790a0d48 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -986,12 +986,10 @@ static bool extract_if_dead(struct connectdata *conn,
/* briefly attach the connection to this transfer for the purpose of
checking it */
Curl_attach_connnection(data, conn);
- conn->data = data; /* find the way back if necessary */
state = conn->handler->connection_check(data, conn, CONNCHECK_ISDEAD);
dead = (state & CONNRESULT_DEAD);
/* detach the connection again */
Curl_detach_connnection(data);
- conn->data = NULL; /* clear it again */
}
else {
/* Use the general method for determining the death of a connection */
@@ -1266,16 +1264,14 @@ ConnectionExists(struct Curl_easy *data,
}
#endif
- DEBUGASSERT(!check->data || GOOD_EASY_HANDLE(check->data));
-
- if(!canmultiplex && check->data)
+ if(!canmultiplex)
/* this request can't be multiplexed but the checked connection is
already in use so we skip it */
continue;
- if(check->data && (check->data->multi != needle->data->multi))
+ if(check->bundle && (check->bundle != needle->bundle))
/* this could be subject for multiplex use, but only if they belong to
- * the same multi handle */
+ * the same connection bundle */
continue;
if(needle->localdev || needle->localport) {
@@ -1435,7 +1431,7 @@ ConnectionExists(struct Curl_easy *data,
continue;
}
else if(multiplexed >=
- Curl_multi_max_concurrent_streams(needle->data->multi)) {
+ Curl_multi_max_concurrent_streams(data->multi)) {
infof(data, "client side MAX_CONCURRENT_STREAMS reached"
", skip (%zu)\n",
multiplexed);
@@ -1459,7 +1455,6 @@ ConnectionExists(struct Curl_easy *data,
if(chosen) {
/* mark it as used before releasing the lock */
- chosen->data = data; /* own it! */
Curl_attach_connnection(data, chosen);
CONNCACHE_UNLOCK(data);
*usethis = chosen;
@@ -1677,9 +1672,6 @@ static struct connectdata *allocate_conn(struct Curl_easy *data)
/* Store off the configured connection upkeep time. */
conn->upkeep_interval_ms = data->set.upkeep_interval_ms;
- conn->data = data; /* Setup the association between this connection
- and the Curl_easy */
-
#ifndef CURL_DISABLE_PROXY
conn->http_proxy.proxytype = data->set.proxytype;
conn->socks_proxy.proxytype = CURLPROXY_SOCKS4;
@@ -3374,8 +3366,6 @@ static void reuse_conn(struct Curl_easy *data,
allocated in vain and is targeted for destruction */
Curl_free_primary_ssl_config(&old_conn->ssl_config);
- conn->data = data;
-
/* get the user+password information from the old_conn struct since it may
* be new for this request even when we re-use an existing connection */
conn->bits.user_passwd = old_conn->bits.user_passwd;
@@ -3459,7 +3449,6 @@ static void reuse_conn(struct Curl_easy *data,
* @param async is set TRUE when an async DNS resolution is pending
* @see Curl_setup_conn()
*
- * *NOTE* this function assigns the conn->data pointer!
*/
static CURLcode create_conn(struct Curl_easy *data,
@@ -3942,8 +3931,6 @@ out:
* create_conn() is all done.
*
* Curl_setup_conn() also handles reused connections
- *
- * conn->data MUST already have been setup fine (in create_conn)
*/
CURLcode Curl_setup_conn(struct Curl_easy *data,
diff --git a/lib/urldata.h b/lib/urldata.h
index 95ef175a1..a10887265 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -902,10 +902,6 @@ struct connstate {
* unique for an entire connection.
*/
struct connectdata {
- /* 'data' is the CURRENT Curl_easy using this connection -- take great
- caution that this might very well vary between different times this
- connection is used! */
- struct Curl_easy *data;
struct connstate cnnct;
struct Curl_llist_element bundle_node; /* conncache */
diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
index f99b663aa..b6d952cb6 100644
--- a/lib/vtls/openssl.c
+++ b/lib/vtls/openssl.c
@@ -2063,17 +2063,14 @@ static void ssl_tls_trace(int direction, int ssl_ver, int content_type,
const void *buf, size_t len, SSL *ssl,
void *userp)
{
- struct Curl_easy *data;
+ struct Curl_easy *data = userp;
char unknown[32];
const char *verstr = NULL;
- struct connectdata *conn = userp;
- if(!conn || !conn->data || !conn->data->set.fdebug ||
+ if(!data || !data->set.fdebug ||
(direction != 0 && direction != 1))
return;
- data = conn->data;
-
switch(ssl_ver) {
#ifdef SSL2_VERSION /* removed in recent versions */
case SSL2_VERSION:
@@ -2610,7 +2607,7 @@ static CURLcode ossl_connect_step1(struct Curl_easy *data,
if(data->set.fdebug && data->set.verbose) {
/* the SSL trace callback is only used for verbose logging */
SSL_CTX_set_msg_callback(backend->ctx, ssl_tls_trace);
- SSL_CTX_set_msg_callback_arg(backend->ctx, conn);
+ SSL_CTX_set_msg_callback_arg(backend->ctx, data);
}
#endif