summaryrefslogtreecommitdiff
path: root/libs/libcurl/src/conncache.c
diff options
context:
space:
mode:
Diffstat (limited to 'libs/libcurl/src/conncache.c')
-rw-r--r--libs/libcurl/src/conncache.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/libs/libcurl/src/conncache.c b/libs/libcurl/src/conncache.c
index cb3170c480..8dfdc0ac81 100644
--- a/libs/libcurl/src/conncache.c
+++ b/libs/libcurl/src/conncache.c
@@ -6,7 +6,7 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2012 - 2016, Linus Nielsen Feltzing, <linus@haxx.se>
- * Copyright (C) 2012 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2012 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -179,12 +179,14 @@ size_t Curl_conncache_size(struct Curl_easy *data)
connectdata struct is setup to use.
**NOTE**: When it returns, it holds the connection cache lock! */
-struct connectbundle *Curl_conncache_find_bundle(struct connectdata *conn,
- struct conncache *connc,
- const char **hostp)
+struct connectbundle *
+Curl_conncache_find_bundle(struct Curl_easy *data,
+ struct connectdata *conn,
+ struct conncache *connc,
+ const char **hostp)
{
struct connectbundle *bundle = NULL;
- CONNCACHE_LOCK(conn->data);
+ CONNCACHE_LOCK(data);
if(connc) {
char key[HASHKEY_SIZE];
hashkey(conn, key, sizeof(key), hostp);
@@ -227,15 +229,17 @@ static void conncache_remove_bundle(struct conncache *connc,
}
}
-CURLcode Curl_conncache_add_conn(struct conncache *connc,
- struct connectdata *conn)
+CURLcode Curl_conncache_add_conn(struct Curl_easy *data)
{
CURLcode result = CURLE_OK;
struct connectbundle *bundle = NULL;
- struct Curl_easy *data = conn->data;
+ struct connectdata *conn = data->conn;
+ struct conncache *connc = data->state.conn_cache;
+ DEBUGASSERT(conn);
/* *find_bundle() locks the connection cache */
- bundle = Curl_conncache_find_bundle(conn, data->state.conn_cache, NULL);
+ bundle = Curl_conncache_find_bundle(data, conn, data->state.conn_cache,
+ NULL);
if(!bundle) {
int rc;
char key[HASHKEY_SIZE];
@@ -259,7 +263,7 @@ CURLcode Curl_conncache_add_conn(struct conncache *connc,
conn->connection_id = connc->next_connection_id++;
connc->num_conn++;
- DEBUGF(infof(conn->data, "Added connection %ld. "
+ DEBUGF(infof(data, "Added connection %ld. "
"The cache now contains %zu members\n",
conn->connection_id, connc->num_conn));
@@ -270,8 +274,8 @@ CURLcode Curl_conncache_add_conn(struct conncache *connc,
}
/*
- * Removes the connectdata object from the connection cache, but does *not*
- * clear the conn->data association. The transfer still owns this connection.
+ * Removes the connectdata object from the connection cache, but the transfer
+ * still owns this connection.
*
* Pass TRUE/FALSE in the 'lock' argument depending on if the parent function
* already holds the lock or not.
@@ -318,7 +322,8 @@ void Curl_conncache_remove_conn(struct Curl_easy *data,
bool Curl_conncache_foreach(struct Curl_easy *data,
struct conncache *connc,
void *param,
- int (*func)(struct connectdata *conn, void *param))
+ int (*func)(struct Curl_easy *data,
+ struct connectdata *conn, void *param))
{
struct Curl_hash_iterator iter;
struct Curl_llist_element *curr;
@@ -344,7 +349,7 @@ bool Curl_conncache_foreach(struct Curl_easy *data,
struct connectdata *conn = curr->ptr;
curr = curr->next;
- if(1 == func(conn, param)) {
+ if(1 == func(data, conn, param)) {
CONNCACHE_UNLOCK(data);
return TRUE;
}
@@ -444,7 +449,7 @@ Curl_conncache_extract_bundle(struct Curl_easy *data,
while(curr) {
conn = curr->ptr;
- if(!CONN_INUSE(conn) && !conn->data) {
+ if(!CONN_INUSE(conn)) {
/* Set higher score for the age passed since the connection was used */
score = Curl_timediff(now, conn->lastused);
@@ -502,7 +507,7 @@ Curl_conncache_extract_oldest(struct Curl_easy *data)
while(curr) {
conn = curr->ptr;
- if(!CONN_INUSE(conn) && !conn->data && !conn->bits.close &&
+ if(!CONN_INUSE(conn) && !conn->bits.close &&
!conn->bits.connect_only) {
/* Set higher score for the age passed since the connection was used */
score = Curl_timediff(now, conn->lastused);
@@ -543,12 +548,10 @@ void Curl_conncache_close_all_connections(struct conncache *connc)
conn = conncache_find_first_connection(connc);
while(conn) {
SIGPIPE_VARIABLE(pipe_st);
- conn->data = connc->closure_handle;
-
- sigpipe_ignore(conn->data, &pipe_st);
+ sigpipe_ignore(connc->closure_handle, &pipe_st);
/* This will remove the connection from the cache */
connclose(conn, "kill all");
- Curl_conncache_remove_conn(conn->data, conn, TRUE);
+ Curl_conncache_remove_conn(connc->closure_handle, conn, TRUE);
(void)Curl_disconnect(connc->closure_handle, conn, FALSE);
sigpipe_restore(&pipe_st);