From: Daniel Stenberg Date: Mon, 25 Apr 2022 14:25:42 +0000 (+0200) Subject: conncache: remove name arg from Curl_conncache_find_bundle X-Git-Tag: curl-7_83_0~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=030adbceebb209df0486d07d76dedce73238055a;p=thirdparty%2Fcurl.git conncache: remove name arg from Curl_conncache_find_bundle To simplify, and also since the returned name is not the full actual name used for the check. The port number and zone id is also involved, so just showing the name is misleading. Closes #8750 --- diff --git a/lib/conncache.c b/lib/conncache.c index 8948b53fa5..aa29620fa3 100644 --- a/lib/conncache.c +++ b/lib/conncache.c @@ -132,13 +132,11 @@ 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 */ - const char **hostp) +static void hashkey(struct connectdata *conn, char *buf, size_t len) { const char *hostname; long port = conn->remote_port; - + DEBUGASSERT(len >= HASHKEY_SIZE); #ifndef CURL_DISABLE_PROXY if(conn->bits.httpproxy && !conn->bits.tunnel_proxy) { hostname = conn->http_proxy.host.name; @@ -151,10 +149,6 @@ static void hashkey(struct connectdata *conn, char *buf, else hostname = conn->host.name; - if(hostp) - /* report back which name we used */ - *hostp = hostname; - /* put the numbers first so that the hostname gets cut off if too long */ #ifdef ENABLE_IPV6 msnprintf(buf, len, "%u/%ld/%s", conn->scope_id, port, hostname); @@ -183,14 +177,13 @@ size_t Curl_conncache_size(struct Curl_easy *data) struct connectbundle * Curl_conncache_find_bundle(struct Curl_easy *data, struct connectdata *conn, - struct conncache *connc, - const char **hostp) + struct conncache *connc) { struct connectbundle *bundle = NULL; CONNCACHE_LOCK(data); if(connc) { char key[HASHKEY_SIZE]; - hashkey(conn, key, sizeof(key), hostp); + hashkey(conn, key, sizeof(key)); bundle = Curl_hash_pick(&connc->hash, key, strlen(key)); } @@ -237,8 +230,7 @@ CURLcode Curl_conncache_add_conn(struct Curl_easy *data) DEBUGASSERT(conn); /* *find_bundle() locks the connection cache */ - bundle = Curl_conncache_find_bundle(data, conn, data->state.conn_cache, - NULL); + bundle = Curl_conncache_find_bundle(data, conn, data->state.conn_cache); if(!bundle) { char key[HASHKEY_SIZE]; @@ -247,7 +239,7 @@ CURLcode Curl_conncache_add_conn(struct Curl_easy *data) goto unlock; } - hashkey(conn, key, sizeof(key), NULL); + hashkey(conn, key, sizeof(key)); if(!conncache_add_bundle(data->state.conn_cache, key, bundle)) { bundle_destroy(bundle); diff --git a/lib/conncache.h b/lib/conncache.h index e9c1e32f87..ef11dcfd29 100644 --- a/lib/conncache.h +++ b/lib/conncache.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2015 - 2021, Daniel Stenberg, , et al. + * Copyright (C) 2015 - 2022, Daniel Stenberg, , et al. * Copyright (C) 2012 - 2014, Linus Nielsen Feltzing, * * This software is licensed as described in the file COPYING, which @@ -87,8 +87,7 @@ void Curl_conncache_destroy(struct conncache *connc); /* return the correct bundle, to a host or a proxy */ struct connectbundle *Curl_conncache_find_bundle(struct Curl_easy *data, struct connectdata *conn, - struct conncache *connc, - const char **hostp); + struct conncache *connc); /* 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 e1647b1338..ef48ed612c 100644 --- a/lib/url.c +++ b/lib/url.c @@ -1123,7 +1123,6 @@ ConnectionExists(struct Curl_easy *data, bool foundPendingCandidate = FALSE; bool canmultiplex = IsMultiplexingPossible(data, needle); struct connectbundle *bundle; - const char *hostbundle; #ifdef USE_NTLM bool wantNTLMhttp = ((data->state.authhost.want & @@ -1144,15 +1143,14 @@ 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(data, needle, data->state.conn_cache, - &hostbundle); + bundle = Curl_conncache_find_bundle(data, needle, data->state.conn_cache); 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]", - hostbundle, (void *)bundle, (bundle->multiuse == BUNDLE_MULTIPLEX ? - "can multiplex" : "serially")); + infof(data, "Found bundle for host: %p [%s]", + (void *)bundle, (bundle->multiuse == BUNDLE_MULTIPLEX ? + "can multiplex" : "serially")); /* We can't multiplex if we don't know anything about the server */ if(canmultiplex) { @@ -3955,10 +3953,8 @@ 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(data, conn, data->state.conn_cache, - &bundlehost); + Curl_conncache_find_bundle(data, conn, data->state.conn_cache); if(max_host_connections > 0 && bundle && (bundle->num_connections >= max_host_connections)) { @@ -3971,8 +3967,8 @@ static CURLcode create_conn(struct Curl_easy *data, if(conn_candidate) Curl_disconnect(data, conn_candidate, FALSE); else { - infof(data, "No more connections allowed to host %s: %zu", - bundlehost, max_host_connections); + infof(data, "No more connections allowed to host: %zu", + max_host_connections); connections_available = FALSE; } }