mirror of
https://github.com/curl/curl.git
synced 2026-08-25 02:03:36 +03:00
dnscache: slight refactoring
Slight refactoring around dnscache, e.g. hostcache - eliminate `data->state.hostcache`. Always look up relevant dnscache at share/multi. - unify naming to "dnscache", replacing "hostcache" - use `struct Curl_dnscache`, even though it just contains a `Curl_hash` for now. - add `Curl_dnscache_destroy()` for cleanup in share/multi. Closes #16941
This commit is contained in:
parent
6140a574de
commit
01e76702ac
14 changed files with 217 additions and 255 deletions
|
|
@ -41,7 +41,7 @@
|
|||
#include "memdebug.h" /* LAST include file */
|
||||
|
||||
static struct Curl_easy *testdata;
|
||||
static struct Curl_hash hp;
|
||||
static struct Curl_dnscache hp;
|
||||
static char *data_key;
|
||||
static struct Curl_dns_entry *data_node;
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ static CURLcode unit_setup(void)
|
|||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
Curl_init_dnscache(&hp, 7);
|
||||
Curl_dnscache_init(&hp, 7);
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ static void unit_stop(void)
|
|||
free(data_node);
|
||||
}
|
||||
free(data_key);
|
||||
Curl_hash_destroy(&hp);
|
||||
Curl_dnscache_destroy(&hp);
|
||||
|
||||
curl_easy_cleanup(testdata);
|
||||
curl_global_cleanup();
|
||||
|
|
@ -122,7 +122,7 @@ UNITTEST_START
|
|||
key_len = strlen(data_key);
|
||||
|
||||
data_node->refcount = 1; /* hash will hold the reference */
|
||||
nodep = Curl_hash_add(&hp, data_key, key_len + 1, data_node);
|
||||
nodep = Curl_hash_add(&hp.entries, data_key, key_len + 1, data_node);
|
||||
abort_unless(nodep, "insertion into hash failed");
|
||||
/* Freeing will now be done by Curl_hash_destroy */
|
||||
data_node = NULL;
|
||||
|
|
|
|||
|
|
@ -139,7 +139,8 @@ UNITTEST_START
|
|||
entry_id = (void *)aprintf("%s:%d", tests[i].host, tests[i].port);
|
||||
if(!entry_id)
|
||||
goto error;
|
||||
dns = Curl_hash_pick(easy->dns.hostcache, entry_id, strlen(entry_id) + 1);
|
||||
dns = Curl_hash_pick(&multi->dnscache.entries,
|
||||
entry_id, strlen(entry_id) + 1);
|
||||
free(entry_id);
|
||||
entry_id = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -141,7 +141,8 @@ UNITTEST_START
|
|||
if(!entry_id)
|
||||
goto error;
|
||||
|
||||
dns = Curl_hash_pick(easy->dns.hostcache, entry_id, strlen(entry_id) + 1);
|
||||
dns = Curl_hash_pick(&multi->dnscache.entries,
|
||||
entry_id, strlen(entry_id) + 1);
|
||||
free(entry_id);
|
||||
entry_id = NULL;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue