aboutsummaryrefslogtreecommitdiff
path: root/lib/conncache.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2019-05-28 12:14:51 +0200
committerDaniel Stenberg <daniel@haxx.se>2019-05-28 16:23:59 +0200
commit2f11fbf208c78d38e9a19b1224238c4ecff5989f (patch)
tree52ca77fbba326655ca035b53a210248c8f014594 /lib/conncache.c
parent8581e1928ea8e125021408ec071fcedb0276c7fe (diff)
conncache: make "bundles" per host name when doing proxy tunnels
Only HTTP proxy use where multiple host names can be used over the same connection should use the proxy host name for bundles. Reported-by: Tom van der Woerdt Fixes #3951 Closes #3955
Diffstat (limited to 'lib/conncache.c')
-rw-r--r--lib/conncache.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/conncache.c b/lib/conncache.c
index 535091996..2cdfd34d9 100644
--- a/lib/conncache.c
+++ b/lib/conncache.c
@@ -159,19 +159,22 @@ void Curl_conncache_destroy(struct conncache *connc)
/* creates a key to find a bundle for this connection */
static void hashkey(struct connectdata *conn, char *buf,
- size_t len) /* something like 128 is fine */
+ size_t len, /* something like 128 is fine */
+ const char **hostp)
{
const char *hostname;
- if(conn->bits.socksproxy)
- hostname = conn->socks_proxy.host.name;
- else if(conn->bits.httpproxy)
+ if(conn->bits.httpproxy && !conn->bits.tunnel_proxy)
hostname = conn->http_proxy.host.name;
else if(conn->bits.conn_to_host)
hostname = conn->conn_to_host.name;
else
hostname = conn->host.name;
+ if(hostp)
+ /* report back which name we used */
+ *hostp = hostname;
+
DEBUGASSERT(len > 32);
/* put the number first so that the hostname gets cut off if too long */
@@ -212,13 +215,14 @@ size_t Curl_conncache_bundle_size(struct connectdata *conn)
**NOTE**: When it returns, it holds the connection cache lock! */
struct connectbundle *Curl_conncache_find_bundle(struct connectdata *conn,
- struct conncache *connc)
+ struct conncache *connc,
+ const char **hostp)
{
struct connectbundle *bundle = NULL;
CONN_LOCK(conn->data);
if(connc) {
char key[128];
- hashkey(conn, key, sizeof(key));
+ hashkey(conn, key, sizeof(key), hostp);
bundle = Curl_hash_pick(&connc->hash, key, strlen(key));
}
@@ -267,7 +271,7 @@ CURLcode Curl_conncache_add_conn(struct conncache *connc,
struct Curl_easy *data = conn->data;
/* *find_bundle() locks the connection cache */
- bundle = Curl_conncache_find_bundle(conn, data->state.conn_cache);
+ bundle = Curl_conncache_find_bundle(conn, data->state.conn_cache, NULL);
if(!bundle) {
int rc;
char key[128];
@@ -277,7 +281,7 @@ CURLcode Curl_conncache_add_conn(struct conncache *connc,
goto unlock;
}
- hashkey(conn, key, sizeof(key));
+ hashkey(conn, key, sizeof(key), NULL);
rc = conncache_add_bundle(data->state.conn_cache, key, new_bundle);
if(!rc) {