mirror of
https://github.com/moparisthebest/curl
synced 2024-12-23 16:48:49 -05:00
hash: make it 'struct Curl_hash'
As internal global names should use captical C. Closes #5906
This commit is contained in:
parent
9b3f888a00
commit
9e90ff0839
@ -206,8 +206,8 @@ static bool conncache_add_bundle(struct conncache *connc,
|
|||||||
static void conncache_remove_bundle(struct conncache *connc,
|
static void conncache_remove_bundle(struct conncache *connc,
|
||||||
struct connectbundle *bundle)
|
struct connectbundle *bundle)
|
||||||
{
|
{
|
||||||
struct curl_hash_iterator iter;
|
struct Curl_hash_iterator iter;
|
||||||
struct curl_hash_element *he;
|
struct Curl_hash_element *he;
|
||||||
|
|
||||||
if(!connc)
|
if(!connc)
|
||||||
return;
|
return;
|
||||||
@ -320,9 +320,9 @@ bool Curl_conncache_foreach(struct Curl_easy *data,
|
|||||||
void *param,
|
void *param,
|
||||||
int (*func)(struct connectdata *conn, void *param))
|
int (*func)(struct connectdata *conn, void *param))
|
||||||
{
|
{
|
||||||
struct curl_hash_iterator iter;
|
struct Curl_hash_iterator iter;
|
||||||
struct Curl_llist_element *curr;
|
struct Curl_llist_element *curr;
|
||||||
struct curl_hash_element *he;
|
struct Curl_hash_element *he;
|
||||||
|
|
||||||
if(!connc)
|
if(!connc)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -363,8 +363,8 @@ bool Curl_conncache_foreach(struct Curl_easy *data,
|
|||||||
static struct connectdata *
|
static struct connectdata *
|
||||||
conncache_find_first_connection(struct conncache *connc)
|
conncache_find_first_connection(struct conncache *connc)
|
||||||
{
|
{
|
||||||
struct curl_hash_iterator iter;
|
struct Curl_hash_iterator iter;
|
||||||
struct curl_hash_element *he;
|
struct Curl_hash_element *he;
|
||||||
struct connectbundle *bundle;
|
struct connectbundle *bundle;
|
||||||
|
|
||||||
Curl_hash_start_iterate(&connc->hash, &iter);
|
Curl_hash_start_iterate(&connc->hash, &iter);
|
||||||
@ -477,9 +477,9 @@ struct connectdata *
|
|||||||
Curl_conncache_extract_oldest(struct Curl_easy *data)
|
Curl_conncache_extract_oldest(struct Curl_easy *data)
|
||||||
{
|
{
|
||||||
struct conncache *connc = data->state.conn_cache;
|
struct conncache *connc = data->state.conn_cache;
|
||||||
struct curl_hash_iterator iter;
|
struct Curl_hash_iterator iter;
|
||||||
struct Curl_llist_element *curr;
|
struct Curl_llist_element *curr;
|
||||||
struct curl_hash_element *he;
|
struct Curl_hash_element *he;
|
||||||
timediff_t highscore =- 1;
|
timediff_t highscore =- 1;
|
||||||
timediff_t score;
|
timediff_t score;
|
||||||
struct curltime now;
|
struct curltime now;
|
||||||
@ -571,9 +571,9 @@ void Curl_conncache_close_all_connections(struct conncache *connc)
|
|||||||
/* Useful for debugging the connection cache */
|
/* Useful for debugging the connection cache */
|
||||||
void Curl_conncache_print(struct conncache *connc)
|
void Curl_conncache_print(struct conncache *connc)
|
||||||
{
|
{
|
||||||
struct curl_hash_iterator iter;
|
struct Curl_hash_iterator iter;
|
||||||
struct Curl_llist_element *curr;
|
struct Curl_llist_element *curr;
|
||||||
struct curl_hash_element *he;
|
struct Curl_hash_element *he;
|
||||||
|
|
||||||
if(!connc)
|
if(!connc)
|
||||||
return;
|
return;
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
struct conncache {
|
struct conncache {
|
||||||
struct curl_hash hash;
|
struct Curl_hash hash;
|
||||||
size_t num_conn;
|
size_t num_conn;
|
||||||
long next_connection_id;
|
long next_connection_id;
|
||||||
struct curltime last_cleanup;
|
struct curltime last_cleanup;
|
||||||
|
56
lib/hash.c
56
lib/hash.c
@ -34,8 +34,8 @@
|
|||||||
static void
|
static void
|
||||||
hash_element_dtor(void *user, void *element)
|
hash_element_dtor(void *user, void *element)
|
||||||
{
|
{
|
||||||
struct curl_hash *h = (struct curl_hash *) user;
|
struct Curl_hash *h = (struct Curl_hash *) user;
|
||||||
struct curl_hash_element *e = (struct curl_hash_element *) element;
|
struct Curl_hash_element *e = (struct Curl_hash_element *) element;
|
||||||
|
|
||||||
if(e->ptr) {
|
if(e->ptr) {
|
||||||
h->dtor(e->ptr);
|
h->dtor(e->ptr);
|
||||||
@ -54,11 +54,11 @@ hash_element_dtor(void *user, void *element)
|
|||||||
* @unittest: 1603
|
* @unittest: 1603
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
Curl_hash_init(struct curl_hash *h,
|
Curl_hash_init(struct Curl_hash *h,
|
||||||
int slots,
|
int slots,
|
||||||
hash_function hfunc,
|
hash_function hfunc,
|
||||||
comp_function comparator,
|
comp_function comparator,
|
||||||
curl_hash_dtor dtor)
|
Curl_hash_dtor dtor)
|
||||||
{
|
{
|
||||||
if(!slots || !hfunc || !comparator ||!dtor) {
|
if(!slots || !hfunc || !comparator ||!dtor) {
|
||||||
return 1; /* failure */
|
return 1; /* failure */
|
||||||
@ -81,11 +81,11 @@ Curl_hash_init(struct curl_hash *h,
|
|||||||
return 1; /* failure */
|
return 1; /* failure */
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct curl_hash_element *
|
static struct Curl_hash_element *
|
||||||
mk_hash_element(const void *key, size_t key_len, const void *p)
|
mk_hash_element(const void *key, size_t key_len, const void *p)
|
||||||
{
|
{
|
||||||
/* allocate the struct plus memory after it to store the key */
|
/* allocate the struct plus memory after it to store the key */
|
||||||
struct curl_hash_element *he = malloc(sizeof(struct curl_hash_element) +
|
struct Curl_hash_element *he = malloc(sizeof(struct Curl_hash_element) +
|
||||||
key_len);
|
key_len);
|
||||||
if(he) {
|
if(he) {
|
||||||
/* copy the key */
|
/* copy the key */
|
||||||
@ -106,14 +106,14 @@ mk_hash_element(const void *key, size_t key_len, const void *p)
|
|||||||
* @unittest: 1603
|
* @unittest: 1603
|
||||||
*/
|
*/
|
||||||
void *
|
void *
|
||||||
Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p)
|
Curl_hash_add(struct Curl_hash *h, void *key, size_t key_len, void *p)
|
||||||
{
|
{
|
||||||
struct curl_hash_element *he;
|
struct Curl_hash_element *he;
|
||||||
struct Curl_llist_element *le;
|
struct Curl_llist_element *le;
|
||||||
struct Curl_llist *l = FETCH_LIST(h, key, key_len);
|
struct Curl_llist *l = FETCH_LIST(h, key, key_len);
|
||||||
|
|
||||||
for(le = l->head; le; le = le->next) {
|
for(le = l->head; le; le = le->next) {
|
||||||
he = (struct curl_hash_element *) le->ptr;
|
he = (struct Curl_hash_element *) le->ptr;
|
||||||
if(h->comp_func(he->key, he->key_len, key, key_len)) {
|
if(h->comp_func(he->key, he->key_len, key, key_len)) {
|
||||||
Curl_llist_remove(l, le, (void *)h);
|
Curl_llist_remove(l, le, (void *)h);
|
||||||
--h->size;
|
--h->size;
|
||||||
@ -136,13 +136,13 @@ Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p)
|
|||||||
*
|
*
|
||||||
* @unittest: 1603
|
* @unittest: 1603
|
||||||
*/
|
*/
|
||||||
int Curl_hash_delete(struct curl_hash *h, void *key, size_t key_len)
|
int Curl_hash_delete(struct Curl_hash *h, void *key, size_t key_len)
|
||||||
{
|
{
|
||||||
struct Curl_llist_element *le;
|
struct Curl_llist_element *le;
|
||||||
struct Curl_llist *l = FETCH_LIST(h, key, key_len);
|
struct Curl_llist *l = FETCH_LIST(h, key, key_len);
|
||||||
|
|
||||||
for(le = l->head; le; le = le->next) {
|
for(le = l->head; le; le = le->next) {
|
||||||
struct curl_hash_element *he = le->ptr;
|
struct Curl_hash_element *he = le->ptr;
|
||||||
if(h->comp_func(he->key, he->key_len, key, key_len)) {
|
if(h->comp_func(he->key, he->key_len, key, key_len)) {
|
||||||
Curl_llist_remove(l, le, (void *) h);
|
Curl_llist_remove(l, le, (void *) h);
|
||||||
--h->size;
|
--h->size;
|
||||||
@ -157,7 +157,7 @@ int Curl_hash_delete(struct curl_hash *h, void *key, size_t key_len)
|
|||||||
* @unittest: 1603
|
* @unittest: 1603
|
||||||
*/
|
*/
|
||||||
void *
|
void *
|
||||||
Curl_hash_pick(struct curl_hash *h, void *key, size_t key_len)
|
Curl_hash_pick(struct Curl_hash *h, void *key, size_t key_len)
|
||||||
{
|
{
|
||||||
struct Curl_llist_element *le;
|
struct Curl_llist_element *le;
|
||||||
struct Curl_llist *l;
|
struct Curl_llist *l;
|
||||||
@ -165,7 +165,7 @@ Curl_hash_pick(struct curl_hash *h, void *key, size_t key_len)
|
|||||||
if(h) {
|
if(h) {
|
||||||
l = FETCH_LIST(h, key, key_len);
|
l = FETCH_LIST(h, key, key_len);
|
||||||
for(le = l->head; le; le = le->next) {
|
for(le = l->head; le; le = le->next) {
|
||||||
struct curl_hash_element *he = le->ptr;
|
struct Curl_hash_element *he = le->ptr;
|
||||||
if(h->comp_func(he->key, he->key_len, key, key_len)) {
|
if(h->comp_func(he->key, he->key_len, key, key_len)) {
|
||||||
return he->ptr;
|
return he->ptr;
|
||||||
}
|
}
|
||||||
@ -177,7 +177,7 @@ Curl_hash_pick(struct curl_hash *h, void *key, size_t key_len)
|
|||||||
|
|
||||||
#if defined(DEBUGBUILD) && defined(AGGRESIVE_TEST)
|
#if defined(DEBUGBUILD) && defined(AGGRESIVE_TEST)
|
||||||
void
|
void
|
||||||
Curl_hash_apply(curl_hash *h, void *user,
|
Curl_hash_apply(Curl_hash *h, void *user,
|
||||||
void (*cb)(void *user, void *ptr))
|
void (*cb)(void *user, void *ptr))
|
||||||
{
|
{
|
||||||
struct Curl_llist_element *le;
|
struct Curl_llist_element *le;
|
||||||
@ -187,7 +187,7 @@ Curl_hash_apply(curl_hash *h, void *user,
|
|||||||
for(le = (h->table[i])->head;
|
for(le = (h->table[i])->head;
|
||||||
le;
|
le;
|
||||||
le = le->next) {
|
le = le->next) {
|
||||||
curl_hash_element *el = le->ptr;
|
Curl_hash_element *el = le->ptr;
|
||||||
cb(user, el->ptr);
|
cb(user, el->ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -202,7 +202,7 @@ Curl_hash_apply(curl_hash *h, void *user,
|
|||||||
* @unittest: 1603
|
* @unittest: 1603
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Curl_hash_destroy(struct curl_hash *h)
|
Curl_hash_destroy(struct Curl_hash *h)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -220,14 +220,14 @@ Curl_hash_destroy(struct curl_hash *h)
|
|||||||
* @unittest: 1602
|
* @unittest: 1602
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Curl_hash_clean(struct curl_hash *h)
|
Curl_hash_clean(struct Curl_hash *h)
|
||||||
{
|
{
|
||||||
Curl_hash_clean_with_criterium(h, NULL, NULL);
|
Curl_hash_clean_with_criterium(h, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cleans all entries that pass the comp function criteria. */
|
/* Cleans all entries that pass the comp function criteria. */
|
||||||
void
|
void
|
||||||
Curl_hash_clean_with_criterium(struct curl_hash *h, void *user,
|
Curl_hash_clean_with_criterium(struct Curl_hash *h, void *user,
|
||||||
int (*comp)(void *, void *))
|
int (*comp)(void *, void *))
|
||||||
{
|
{
|
||||||
struct Curl_llist_element *le;
|
struct Curl_llist_element *le;
|
||||||
@ -242,7 +242,7 @@ Curl_hash_clean_with_criterium(struct curl_hash *h, void *user,
|
|||||||
list = &h->table[i];
|
list = &h->table[i];
|
||||||
le = list->head; /* get first list entry */
|
le = list->head; /* get first list entry */
|
||||||
while(le) {
|
while(le) {
|
||||||
struct curl_hash_element *he = le->ptr;
|
struct Curl_hash_element *he = le->ptr;
|
||||||
lnext = le->next;
|
lnext = le->next;
|
||||||
/* ask the callback function if we shall remove this entry or not */
|
/* ask the callback function if we shall remove this entry or not */
|
||||||
if(comp == NULL || comp(user, he->ptr)) {
|
if(comp == NULL || comp(user, he->ptr)) {
|
||||||
@ -277,18 +277,18 @@ size_t Curl_str_key_compare(void *k1, size_t key1_len,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Curl_hash_start_iterate(struct curl_hash *hash,
|
void Curl_hash_start_iterate(struct Curl_hash *hash,
|
||||||
struct curl_hash_iterator *iter)
|
struct Curl_hash_iterator *iter)
|
||||||
{
|
{
|
||||||
iter->hash = hash;
|
iter->hash = hash;
|
||||||
iter->slot_index = 0;
|
iter->slot_index = 0;
|
||||||
iter->current_element = NULL;
|
iter->current_element = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct curl_hash_element *
|
struct Curl_hash_element *
|
||||||
Curl_hash_next_element(struct curl_hash_iterator *iter)
|
Curl_hash_next_element(struct Curl_hash_iterator *iter)
|
||||||
{
|
{
|
||||||
struct curl_hash *h = iter->hash;
|
struct Curl_hash *h = iter->hash;
|
||||||
|
|
||||||
/* Get the next element in the current list, if any */
|
/* Get the next element in the current list, if any */
|
||||||
if(iter->current_element)
|
if(iter->current_element)
|
||||||
@ -307,7 +307,7 @@ Curl_hash_next_element(struct curl_hash_iterator *iter)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(iter->current_element) {
|
if(iter->current_element) {
|
||||||
struct curl_hash_element *he = iter->current_element->ptr;
|
struct Curl_hash_element *he = iter->current_element->ptr;
|
||||||
return he;
|
return he;
|
||||||
}
|
}
|
||||||
iter->current_element = NULL;
|
iter->current_element = NULL;
|
||||||
@ -315,11 +315,11 @@ Curl_hash_next_element(struct curl_hash_iterator *iter)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if 0 /* useful function for debugging hashes and their contents */
|
#if 0 /* useful function for debugging hashes and their contents */
|
||||||
void Curl_hash_print(struct curl_hash *h,
|
void Curl_hash_print(struct Curl_hash *h,
|
||||||
void (*func)(void *))
|
void (*func)(void *))
|
||||||
{
|
{
|
||||||
struct curl_hash_iterator iter;
|
struct Curl_hash_iterator iter;
|
||||||
struct curl_hash_element *he;
|
struct Curl_hash_element *he;
|
||||||
int last_index = -1;
|
int last_index = -1;
|
||||||
|
|
||||||
if(!h)
|
if(!h)
|
||||||
|
40
lib/hash.h
40
lib/hash.h
@ -41,9 +41,9 @@ typedef size_t (*comp_function) (void *key1,
|
|||||||
void *key2,
|
void *key2,
|
||||||
size_t key2_len);
|
size_t key2_len);
|
||||||
|
|
||||||
typedef void (*curl_hash_dtor)(void *);
|
typedef void (*Curl_hash_dtor)(void *);
|
||||||
|
|
||||||
struct curl_hash {
|
struct Curl_hash {
|
||||||
struct Curl_llist *table;
|
struct Curl_llist *table;
|
||||||
|
|
||||||
/* Hash function to be used for this hash table */
|
/* Hash function to be used for this hash table */
|
||||||
@ -51,49 +51,49 @@ struct curl_hash {
|
|||||||
|
|
||||||
/* Comparator function to compare keys */
|
/* Comparator function to compare keys */
|
||||||
comp_function comp_func;
|
comp_function comp_func;
|
||||||
curl_hash_dtor dtor;
|
Curl_hash_dtor dtor;
|
||||||
int slots;
|
int slots;
|
||||||
size_t size;
|
size_t size;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct curl_hash_element {
|
struct Curl_hash_element {
|
||||||
struct Curl_llist_element list;
|
struct Curl_llist_element list;
|
||||||
void *ptr;
|
void *ptr;
|
||||||
size_t key_len;
|
size_t key_len;
|
||||||
char key[1]; /* allocated memory following the struct */
|
char key[1]; /* allocated memory following the struct */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct curl_hash_iterator {
|
struct Curl_hash_iterator {
|
||||||
struct curl_hash *hash;
|
struct Curl_hash *hash;
|
||||||
int slot_index;
|
int slot_index;
|
||||||
struct Curl_llist_element *current_element;
|
struct Curl_llist_element *current_element;
|
||||||
};
|
};
|
||||||
|
|
||||||
int Curl_hash_init(struct curl_hash *h,
|
int Curl_hash_init(struct Curl_hash *h,
|
||||||
int slots,
|
int slots,
|
||||||
hash_function hfunc,
|
hash_function hfunc,
|
||||||
comp_function comparator,
|
comp_function comparator,
|
||||||
curl_hash_dtor dtor);
|
Curl_hash_dtor dtor);
|
||||||
|
|
||||||
void *Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p);
|
void *Curl_hash_add(struct Curl_hash *h, void *key, size_t key_len, void *p);
|
||||||
int Curl_hash_delete(struct curl_hash *h, void *key, size_t key_len);
|
int Curl_hash_delete(struct Curl_hash *h, void *key, size_t key_len);
|
||||||
void *Curl_hash_pick(struct curl_hash *, void *key, size_t key_len);
|
void *Curl_hash_pick(struct Curl_hash *, void *key, size_t key_len);
|
||||||
void Curl_hash_apply(struct curl_hash *h, void *user,
|
void Curl_hash_apply(struct Curl_hash *h, void *user,
|
||||||
void (*cb)(void *user, void *ptr));
|
void (*cb)(void *user, void *ptr));
|
||||||
#define Curl_hash_count(h) ((h)->size)
|
#define Curl_hash_count(h) ((h)->size)
|
||||||
void Curl_hash_destroy(struct curl_hash *h);
|
void Curl_hash_destroy(struct Curl_hash *h);
|
||||||
void Curl_hash_clean(struct curl_hash *h);
|
void Curl_hash_clean(struct Curl_hash *h);
|
||||||
void Curl_hash_clean_with_criterium(struct curl_hash *h, void *user,
|
void Curl_hash_clean_with_criterium(struct Curl_hash *h, void *user,
|
||||||
int (*comp)(void *, void *));
|
int (*comp)(void *, void *));
|
||||||
size_t Curl_hash_str(void *key, size_t key_length, size_t slots_num);
|
size_t Curl_hash_str(void *key, size_t key_length, size_t slots_num);
|
||||||
size_t Curl_str_key_compare(void *k1, size_t key1_len, void *k2,
|
size_t Curl_str_key_compare(void *k1, size_t key1_len, void *k2,
|
||||||
size_t key2_len);
|
size_t key2_len);
|
||||||
void Curl_hash_start_iterate(struct curl_hash *hash,
|
void Curl_hash_start_iterate(struct Curl_hash *hash,
|
||||||
struct curl_hash_iterator *iter);
|
struct Curl_hash_iterator *iter);
|
||||||
struct curl_hash_element *
|
struct Curl_hash_element *
|
||||||
Curl_hash_next_element(struct curl_hash_iterator *iter);
|
Curl_hash_next_element(struct Curl_hash_iterator *iter);
|
||||||
|
|
||||||
void Curl_hash_print(struct curl_hash *h,
|
void Curl_hash_print(struct Curl_hash *h,
|
||||||
void (*func)(void *));
|
void (*func)(void *));
|
||||||
|
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ hostcache_timestamp_remove(void *datap, void *hc)
|
|||||||
* Prune the DNS cache. This assumes that a lock has already been taken.
|
* Prune the DNS cache. This assumes that a lock has already been taken.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
hostcache_prune(struct curl_hash *hostcache, long cache_timeout, time_t now)
|
hostcache_prune(struct Curl_hash *hostcache, long cache_timeout, time_t now)
|
||||||
{
|
{
|
||||||
struct hostcache_prune_data user;
|
struct hostcache_prune_data user;
|
||||||
|
|
||||||
@ -843,7 +843,7 @@ static void freednsentry(void *freethis)
|
|||||||
/*
|
/*
|
||||||
* Curl_mk_dnscache() inits a new DNS cache and returns success/failure.
|
* Curl_mk_dnscache() inits a new DNS cache and returns success/failure.
|
||||||
*/
|
*/
|
||||||
int Curl_mk_dnscache(struct curl_hash *hash)
|
int Curl_mk_dnscache(struct Curl_hash *hash)
|
||||||
{
|
{
|
||||||
return Curl_hash_init(hash, 7, Curl_hash_str, Curl_str_key_compare,
|
return Curl_hash_init(hash, 7, Curl_hash_str, Curl_str_key_compare,
|
||||||
freednsentry);
|
freednsentry);
|
||||||
@ -857,7 +857,7 @@ int Curl_mk_dnscache(struct curl_hash *hash)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
void Curl_hostcache_clean(struct Curl_easy *data,
|
void Curl_hostcache_clean(struct Curl_easy *data,
|
||||||
struct curl_hash *hash)
|
struct Curl_hash *hash)
|
||||||
{
|
{
|
||||||
if(data && data->share)
|
if(data && data->share)
|
||||||
Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);
|
Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);
|
||||||
|
@ -59,9 +59,9 @@ struct connectdata;
|
|||||||
* Global DNS cache is general badness. Do not use. This will be removed in
|
* Global DNS cache is general badness. Do not use. This will be removed in
|
||||||
* a future version. Use the share interface instead!
|
* a future version. Use the share interface instead!
|
||||||
*
|
*
|
||||||
* Returns a struct curl_hash pointer on success, NULL on failure.
|
* Returns a struct Curl_hash pointer on success, NULL on failure.
|
||||||
*/
|
*/
|
||||||
struct curl_hash *Curl_global_host_cache_init(void);
|
struct Curl_hash *Curl_global_host_cache_init(void);
|
||||||
|
|
||||||
struct Curl_dns_entry {
|
struct Curl_dns_entry {
|
||||||
struct Curl_addrinfo *addr;
|
struct Curl_addrinfo *addr;
|
||||||
@ -128,7 +128,7 @@ void Curl_resolv_unlock(struct Curl_easy *data,
|
|||||||
struct Curl_dns_entry *dns);
|
struct Curl_dns_entry *dns);
|
||||||
|
|
||||||
/* init a new dns cache and return success */
|
/* init a new dns cache and return success */
|
||||||
int Curl_mk_dnscache(struct curl_hash *hash);
|
int Curl_mk_dnscache(struct Curl_hash *hash);
|
||||||
|
|
||||||
/* prune old entries from the DNS cache */
|
/* prune old entries from the DNS cache */
|
||||||
void Curl_hostcache_prune(struct Curl_easy *data);
|
void Curl_hostcache_prune(struct Curl_easy *data);
|
||||||
@ -234,7 +234,7 @@ CURLcode Curl_set_dns_local_ip6(struct Curl_easy *data,
|
|||||||
/*
|
/*
|
||||||
* Clean off entries from the cache
|
* Clean off entries from the cache
|
||||||
*/
|
*/
|
||||||
void Curl_hostcache_clean(struct Curl_easy *data, struct curl_hash *hash);
|
void Curl_hostcache_clean(struct Curl_easy *data, struct Curl_hash *hash);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Populate the cache with specified entries from CURLOPT_RESOLVE.
|
* Populate the cache with specified entries from CURLOPT_RESOLVE.
|
||||||
|
14
lib/multi.c
14
lib/multi.c
@ -190,7 +190,7 @@ static void mstate(struct Curl_easy *data, CURLMstate state
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
struct Curl_sh_entry {
|
struct Curl_sh_entry {
|
||||||
struct curl_hash transfers; /* hash of transfers using this socket */
|
struct Curl_hash transfers; /* hash of transfers using this socket */
|
||||||
unsigned int action; /* what combined action READ/WRITE this socket waits
|
unsigned int action; /* what combined action READ/WRITE this socket waits
|
||||||
for */
|
for */
|
||||||
void *socketp; /* settable by users with curl_multi_assign() */
|
void *socketp; /* settable by users with curl_multi_assign() */
|
||||||
@ -204,7 +204,7 @@ struct Curl_sh_entry {
|
|||||||
#define SH_WRITE 2
|
#define SH_WRITE 2
|
||||||
|
|
||||||
/* look up a given socket in the socket hash, skip invalid sockets */
|
/* look up a given socket in the socket hash, skip invalid sockets */
|
||||||
static struct Curl_sh_entry *sh_getentry(struct curl_hash *sh,
|
static struct Curl_sh_entry *sh_getentry(struct Curl_hash *sh,
|
||||||
curl_socket_t s)
|
curl_socket_t s)
|
||||||
{
|
{
|
||||||
if(s != CURL_SOCKET_BAD) {
|
if(s != CURL_SOCKET_BAD) {
|
||||||
@ -238,7 +238,7 @@ static void trhash_dtor(void *nada)
|
|||||||
|
|
||||||
|
|
||||||
/* make sure this socket is present in the hash for this handle */
|
/* make sure this socket is present in the hash for this handle */
|
||||||
static struct Curl_sh_entry *sh_addentry(struct curl_hash *sh,
|
static struct Curl_sh_entry *sh_addentry(struct Curl_hash *sh,
|
||||||
curl_socket_t s)
|
curl_socket_t s)
|
||||||
{
|
{
|
||||||
struct Curl_sh_entry *there = sh_getentry(sh, s);
|
struct Curl_sh_entry *there = sh_getentry(sh, s);
|
||||||
@ -273,7 +273,7 @@ static struct Curl_sh_entry *sh_addentry(struct curl_hash *sh,
|
|||||||
|
|
||||||
/* delete the given socket + handle from the hash */
|
/* delete the given socket + handle from the hash */
|
||||||
static void sh_delentry(struct Curl_sh_entry *entry,
|
static void sh_delentry(struct Curl_sh_entry *entry,
|
||||||
struct curl_hash *sh, curl_socket_t s)
|
struct Curl_hash *sh, curl_socket_t s)
|
||||||
{
|
{
|
||||||
Curl_hash_destroy(&entry->transfers);
|
Curl_hash_destroy(&entry->transfers);
|
||||||
|
|
||||||
@ -325,7 +325,7 @@ static size_t hash_fd(void *key, size_t key_length, size_t slots_num)
|
|||||||
* per call."
|
* per call."
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static int sh_init(struct curl_hash *hash, int hashsize)
|
static int sh_init(struct Curl_hash *hash, int hashsize)
|
||||||
{
|
{
|
||||||
return Curl_hash_init(hash, hashsize, hash_fd, fd_key_compare,
|
return Curl_hash_init(hash, hashsize, hash_fd, fd_key_compare,
|
||||||
sh_freeentry);
|
sh_freeentry);
|
||||||
@ -2983,8 +2983,8 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
|
|||||||
and just move on. */
|
and just move on. */
|
||||||
;
|
;
|
||||||
else {
|
else {
|
||||||
struct curl_hash_iterator iter;
|
struct Curl_hash_iterator iter;
|
||||||
struct curl_hash_element *he;
|
struct Curl_hash_element *he;
|
||||||
|
|
||||||
/* the socket can be shared by many transfers, iterate */
|
/* the socket can be shared by many transfers, iterate */
|
||||||
Curl_hash_start_iterate(&entry->transfers, &iter);
|
Curl_hash_start_iterate(&entry->transfers, &iter);
|
||||||
|
@ -103,7 +103,7 @@ struct Curl_multi {
|
|||||||
void *push_userp;
|
void *push_userp;
|
||||||
|
|
||||||
/* Hostname cache */
|
/* Hostname cache */
|
||||||
struct curl_hash hostcache;
|
struct Curl_hash hostcache;
|
||||||
|
|
||||||
#ifdef USE_LIBPSL
|
#ifdef USE_LIBPSL
|
||||||
/* PSL cache. */
|
/* PSL cache. */
|
||||||
@ -117,7 +117,7 @@ struct Curl_multi {
|
|||||||
/* 'sockhash' is the lookup hash for socket descriptor => easy handles (note
|
/* 'sockhash' is the lookup hash for socket descriptor => easy handles (note
|
||||||
the pluralis form, there can be more than one easy handle waiting on the
|
the pluralis form, there can be more than one easy handle waiting on the
|
||||||
same actual socket) */
|
same actual socket) */
|
||||||
struct curl_hash sockhash;
|
struct Curl_hash sockhash;
|
||||||
|
|
||||||
/* Shared connection cache (bundles)*/
|
/* Shared connection cache (bundles)*/
|
||||||
struct conncache conn_cache;
|
struct conncache conn_cache;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -46,7 +46,7 @@ struct Curl_share {
|
|||||||
curl_unlock_function unlockfunc;
|
curl_unlock_function unlockfunc;
|
||||||
void *clientdata;
|
void *clientdata;
|
||||||
struct conncache conn_cache;
|
struct conncache conn_cache;
|
||||||
struct curl_hash hostcache;
|
struct Curl_hash hostcache;
|
||||||
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
|
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
|
||||||
struct CookieInfo *cookies;
|
struct CookieInfo *cookies;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1842,7 +1842,7 @@ struct UserDefined {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct Names {
|
struct Names {
|
||||||
struct curl_hash *hostcache;
|
struct Curl_hash *hostcache;
|
||||||
enum {
|
enum {
|
||||||
HCACHE_NONE, /* not pointing to anything */
|
HCACHE_NONE, /* not pointing to anything */
|
||||||
HCACHE_MULTI, /* points to a shared one in the multi handle */
|
HCACHE_MULTI, /* points to a shared one in the multi handle */
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
#include "memdebug.h" /* LAST include file */
|
#include "memdebug.h" /* LAST include file */
|
||||||
|
|
||||||
static struct Curl_easy *data;
|
static struct Curl_easy *data;
|
||||||
static struct curl_hash hp;
|
static struct Curl_hash hp;
|
||||||
static char *data_key;
|
static char *data_key;
|
||||||
static struct Curl_dns_entry *data_node;
|
static struct Curl_dns_entry *data_node;
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#include "memdebug.h" /* LAST include file */
|
#include "memdebug.h" /* LAST include file */
|
||||||
|
|
||||||
static struct curl_hash hash_static;
|
static struct Curl_hash hash_static;
|
||||||
|
|
||||||
static void mydtor(void *p)
|
static void mydtor(void *p)
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 2015 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#include "memdebug.h" /* LAST include file */
|
#include "memdebug.h" /* LAST include file */
|
||||||
|
|
||||||
static struct curl_hash hash_static;
|
static struct Curl_hash hash_static;
|
||||||
static const int slots = 3;
|
static const int slots = 3;
|
||||||
|
|
||||||
static void mydtor(void *p)
|
static void mydtor(void *p)
|
||||||
|
Loading…
Reference in New Issue
Block a user