[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 37/63: conncache: make "bundles" per host name when
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 37/63: conncache: make "bundles" per host name when doing proxy tunnels |
Date: |
Fri, 07 Jun 2019 18:36:59 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit 2f11fbf208c78d38e9a19b1224238c4ecff5989f
Author: Daniel Stenberg <address@hidden>
AuthorDate: Tue May 28 12:14:51 2019 +0200
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
---
lib/conncache.c | 20 ++++++++++++--------
lib/conncache.h | 3 ++-
lib/url.c | 17 +++++++++--------
3 files changed, 23 insertions(+), 17 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) {
diff --git a/lib/conncache.h b/lib/conncache.h
index 35be9e0aa..58f902409 100644
--- a/lib/conncache.h
+++ b/lib/conncache.h
@@ -54,7 +54,8 @@ void Curl_conncache_destroy(struct conncache *connc);
/* return the correct bundle, to a host or a proxy */
struct connectbundle *Curl_conncache_find_bundle(struct connectdata *conn,
- struct conncache *connc);
+ struct conncache *connc,
+ const char **hostp);
void Curl_conncache_unlock(struct Curl_easy *data);
/* returns number of connections currently held in the connection cache */
size_t Curl_conncache_size(struct Curl_easy *data);
diff --git a/lib/url.c b/lib/url.c
index 6a6715403..88d72bfea 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -1006,6 +1006,7 @@ ConnectionExists(struct Curl_easy *data,
bool canmultiplex = IsMultiplexingPossible(data, needle);
struct connectbundle *bundle;
struct curltime now = Curl_now();
+ const char *hostbundle;
#ifdef USE_NTLM
bool wantNTLMhttp = ((data->state.authhost.want &
@@ -1022,16 +1023,15 @@ ConnectionExists(struct Curl_easy *data,
/* Look up the bundle with all the connections to this particular host.
Locks the connection cache, beware of early returns! */
- bundle = Curl_conncache_find_bundle(needle, data->state.conn_cache);
+ bundle = Curl_conncache_find_bundle(needle, data->state.conn_cache,
+ &hostbundle);
if(bundle) {
/* Max pipe length is zero (unlimited) for multiplexed connections */
struct curl_llist_element *curr;
infof(data, "Found bundle for host %s: %p [%s]\n",
- (needle->bits.conn_to_host ? needle->conn_to_host.name :
- needle->host.name), (void *)bundle,
- (bundle->multiuse == BUNDLE_MULTIPLEX ?
- "can multiplex" : "serially"));
+ hostbundle, (void *)bundle, (bundle->multiuse == BUNDLE_MULTIPLEX ?
+ "can multiplex" : "serially"));
/* We can't multiplex if we don't know anything about the server */
if(canmultiplex) {
@@ -3762,8 +3762,9 @@ static CURLcode create_conn(struct Curl_easy *data,
connections_available = FALSE;
else {
/* this gets a lock on the conncache */
+ const char *bundlehost;
struct connectbundle *bundle =
- Curl_conncache_find_bundle(conn, data->state.conn_cache);
+ Curl_conncache_find_bundle(conn, data->state.conn_cache, &bundlehost);
if(max_host_connections > 0 && bundle &&
(bundle->num_connections >= max_host_connections)) {
@@ -3777,8 +3778,8 @@ static CURLcode create_conn(struct Curl_easy *data,
(void)Curl_disconnect(data, conn_candidate,
/* dead_connection */ FALSE);
else {
- infof(data, "No more connections allowed to host: %zu\n",
- max_host_connections);
+ infof(data, "No more connections allowed to host %s: %zu\n",
+ bundlehost, max_host_connections);
connections_available = FALSE;
}
}
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [GNUnet-SVN] [gnurl] 14/63: Revert "progress: CURL_DISABLE_PROGRESS_METER", (continued)
- [GNUnet-SVN] [gnurl] 14/63: Revert "progress: CURL_DISABLE_PROGRESS_METER", gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 23/63: winbuild: Use two space indentation, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 17/63: config-win32: add support for if_nametoindex and getsockname, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 22/63: tool_parse_cfg: Avoid 2 fopen() for WIN32, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 39/63: parse_proxy: make sure portptr is initialized, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 29/63: Revert all SASL authzid (new feature) commits, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 21/63: md4: include the mbedtls config.h to get the MD4 info, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 07/63: hiperfifo: remove unused variable, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 12/63: curl: --sasl-authzid added to support CURLOPT_SASL_AUTHZID from the tool, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 25/63: Fix typo., gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 37/63: conncache: make "bundles" per host name when doing proxy tunnels,
gnunet <=
- [GNUnet-SVN] [gnurl] 35/63: curl-win32.h: Enable Unix Domain Sockets based on the Windows SDK version, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 42/63: appveyor: add support for other build systems, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 43/63: appveyor: add Visual Studio solution build, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 27/63: RELEASE-NOTES: synced, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 45/63: conncache: Remove the DEBUGASSERT on length check, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 33/63: HAProxy tests: add keywords, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 32/63: tests: make test 1420 and 1406 work with rtsp-disabled libcurl, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 51/63: http: don't parse body-related headers bodyless responses, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 53/63: NTLM: reset proxy "multipass" state when CONNECT request is done, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 58/63: curl_share_setopt.3: improve wording [ci ship], gnunet, 2019/06/07