aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/hostip.c15
-rw-r--r--lib/hostip.h14
-rw-r--r--lib/url.c16
-rw-r--r--lib/urldata.h1
4 files changed, 29 insertions, 17 deletions
diff --git a/lib/hostip.c b/lib/hostip.c
index 55225480c..aa5ec1e00 100644
--- a/lib/hostip.c
+++ b/lib/hostip.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2008, 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
@@ -127,14 +127,19 @@ static void freednsentry(void *freethis);
* Curl_global_host_cache_init() initializes and sets up a global DNS cache.
* Global DNS cache is general badness. Do not use. This will be removed in
* a future version. Use the share interface instead!
+ *
+ * Returns 0 on success, 1 on failure.
*/
-void Curl_global_host_cache_init(void)
+int Curl_global_host_cache_init(void)
{
+ int rc = 0;
if(!host_cache_initialized) {
- Curl_hash_init(&hostname_cache, 7, Curl_hash_str, Curl_str_key_compare,
- freednsentry);
- host_cache_initialized = 1;
+ rc = Curl_hash_init(&hostname_cache, 7, Curl_hash_str,
+ Curl_str_key_compare, freednsentry);
+ if(!rc)
+ host_cache_initialized = 1;
}
+ return rc;
}
/*
diff --git a/lib/hostip.h b/lib/hostip.h
index 53093c169..a7e0988a2 100644
--- a/lib/hostip.h
+++ b/lib/hostip.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2008, 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
@@ -125,11 +125,19 @@ struct hostent;
struct SessionHandle;
struct connectdata;
-void Curl_global_host_cache_init(void);
+/*
+ * Curl_global_host_cache_init() initializes and sets up a global DNS cache.
+ * Global DNS cache is general badness. Do not use. This will be removed in
+ * a future version. Use the share interface instead!
+ *
+ * Returns 0 on success, 1 on failure.
+ */
+int Curl_global_host_cache_init(void);
void Curl_global_host_cache_dtor(void);
struct curl_hash *Curl_global_host_cache_get(void);
-#define Curl_global_host_cache_use(__p) ((__p)->set.global_dns_cache)
+#define Curl_global_host_cache_use(__p) \
+ ((__p)->dns.hostcachetype == HCACHE_GLOBAL)
struct Curl_dns_entry {
Curl_addrinfo *addr;
diff --git a/lib/url.c b/lib/url.c
index a5e4565ad..94c363fc2 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -457,11 +457,8 @@ CURLcode Curl_close(struct SessionHandle *data)
return CURLE_OK;
}
- if( ! (data->share && data->share->hostcache) ) {
- if( !Curl_global_host_cache_use(data)) {
- Curl_hash_destroy(data->dns.hostcache);
- }
- }
+ if(data->dns.hostcachetype == HCACHE_PRIVATE)
+ Curl_hash_destroy(data->dns.hostcache);
if(data->state.rangestringalloc)
free(data->state.range);
@@ -782,10 +779,13 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
case CURLOPT_DNS_USE_GLOBAL_CACHE:
{
long use_cache = va_arg(param, long);
- if(use_cache)
+ if(use_cache) {
Curl_global_host_cache_init();
-
- data->set.global_dns_cache = (bool)(0 != use_cache);
+ data->dns.hostcachetype = HCACHE_GLOBAL;
+ }
+ else
+ /* not global makes it private by default then */
+ data->dns.hostcachetype = HCACHE_PRIVATE;
}
break;
case CURLOPT_SSL_CIPHER_LIST:
diff --git a/lib/urldata.h b/lib/urldata.h
index e9e4fb872..f3ca2f80d 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -1443,7 +1443,6 @@ struct UserDefined {
curl_ftpauth ftpsslauth; /* what AUTH XXX to be attempted */
curl_ftpccc ftp_ccc; /* FTP CCC options */
bool no_signal; /* do not use any signal/alarm handler */
- bool global_dns_cache; /* subject for future removal */
bool tcp_nodelay; /* whether to enable TCP_NODELAY or not */
bool ignorecl; /* ignore content length */
bool ftp_skip_ip; /* skip the IP address the FTP server passes on to