summaryrefslogtreecommitdiff
path: root/lib/hash.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2009-11-11 09:31:37 +0000
committerDaniel Stenberg <daniel@haxx.se>2009-11-11 09:31:37 +0000
commitfb5f332834baeee1c9ec27dee6fc065364d5b7f3 (patch)
treecfa2d2f34fcc4201edb86088664c9aacbdfd2016 /lib/hash.c
parent107c4d878abea8940cae85bc9d330c13481ea634 (diff)
downloadcurl-fb5f332834baeee1c9ec27dee6fc065364d5b7f3.tar.gz
- Constantine Sapuntzakis posted bug #2891595
(http://curl.haxx.se/bug/view.cgi?id=2891595) which identified how an entry in the DNS cache would linger too long if the request that added it was in use that long. He also provided the patch that now makes libcurl capable of still doing a request while the DNS hash entry may get timed out.
Diffstat (limited to 'lib/hash.c')
-rw-r--r--lib/hash.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/hash.c b/lib/hash.c
index 6ca7431ce..bcd144a11 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -140,8 +140,8 @@ mk_hash_element(const void *key, size_t key_len, const void *p)
#define FETCH_LIST(x,y,z) x->table[x->hash_func(y, z, x->slots)]
-/* Return the data in the hash. If there already was a match in the hash,
- that data is returned. */
+/* Insert the data in the hash. If there already was a match in the hash,
+ that data is replaced. */
void *
Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p)
{
@@ -152,8 +152,9 @@ Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p)
for (le = l->head; le; le = le->next) {
he = (struct curl_hash_element *) le->ptr;
if(h->comp_func(he->key, he->key_len, key, key_len)) {
- h->dtor(p); /* remove the NEW entry */
- return he->ptr; /* return the EXISTING entry */
+ Curl_llist_remove(l, le, (void *)h);
+ --h->size;
+ break;
}
}