summaryrefslogtreecommitdiff
path: root/plugins/FTPFileYM/curl/lib/hostip.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/FTPFileYM/curl/lib/hostip.c')
-rw-r--r--plugins/FTPFileYM/curl/lib/hostip.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/plugins/FTPFileYM/curl/lib/hostip.c b/plugins/FTPFileYM/curl/lib/hostip.c
index 3765ca1cde..f37b4925bb 100644
--- a/plugins/FTPFileYM/curl/lib/hostip.c
+++ b/plugins/FTPFileYM/curl/lib/hostip.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -140,6 +140,10 @@ struct curl_hash *Curl_global_host_cache_init(void)
void Curl_global_host_cache_dtor(void)
{
if(host_cache_initialized) {
+ /* first make sure that any custom "CURLOPT_RESOLVE" names are
+ cleared off */
+ Curl_hostcache_clean(NULL, &hostname_cache);
+ /* then free the remaining hash completely */
Curl_hash_clean(&hostname_cache);
host_cache_initialized = 0;
}
@@ -681,12 +685,14 @@ clean_up:
* Curl_resolv_unlock() unlocks the given cached DNS entry. When this has been
* made, the struct may be destroyed due to pruning. It is important that only
* one unlock is made for each Curl_resolv() call.
+ *
+ * May be called with 'data' == NULL for global cache.
*/
void Curl_resolv_unlock(struct SessionHandle *data, struct Curl_dns_entry *dns)
{
DEBUGASSERT(dns && (dns->inuse>0));
- if(data->share)
+ if(data && data->share)
Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);
dns->inuse--;
@@ -697,7 +703,7 @@ void Curl_resolv_unlock(struct SessionHandle *data, struct Curl_dns_entry *dns)
free(dns);
}
- if(data->share)
+ if(data && data->share)
Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
}
@@ -734,22 +740,23 @@ static int hostcache_inuse(void *data, void *hc)
return 1; /* free all entries */
}
-void Curl_hostcache_clean(struct SessionHandle *data)
+/*
+ * Curl_hostcache_clean()
+ *
+ * This _can_ be called with 'data' == NULL but then of course no locking
+ * can be done!
+ */
+
+void Curl_hostcache_clean(struct SessionHandle *data,
+ struct curl_hash *hash)
{
/* Entries added to the hostcache with the CURLOPT_RESOLVE function are
* still present in the cache with the inuse counter set to 1. Detect them
* and cleanup!
*/
- Curl_hash_clean_with_criterium(data->dns.hostcache, data, hostcache_inuse);
+ Curl_hash_clean_with_criterium(hash, data, hostcache_inuse);
}
-void Curl_hostcache_destroy(struct SessionHandle *data)
-{
- Curl_hostcache_clean(data);
- Curl_hash_destroy(data->dns.hostcache);
- data->dns.hostcachetype = HCACHE_NONE;
- data->dns.hostcache = NULL;
-}
CURLcode Curl_loadhostpairs(struct SessionHandle *data)
{