diff options
author | Daniel Stenberg <daniel@haxx.se> | 2008-01-15 22:44:12 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2008-01-15 22:44:12 +0000 |
commit | 991505e077f4ecdbd0b1d0f42be0c9b548dc743d (patch) | |
tree | 34b3e98e43004e2a577ffe4f421acdabbcf6170f /lib/easy.c | |
parent | 56f17d2c9f3d229d701bcf0dda83f4d29c0e02ba (diff) |
Woops, partly revert my previous commit and do it slightly differently instead.
The signalling of that a global DNS cache is wanted is done by setting the
option but the setting of the internal variable that it is in use must not be
done until it finally actually gets used!
NOTE and WARNING: I noticed that you can't actually switch off the global dns
cache with CURLOPT_DNS_USE_GLOBAL_CACHE but you couldn't do that previously
either and the option is very clearly and loudly documented as DO NOTE USE so
I won't bother to fix this bug now.
Diffstat (limited to 'lib/easy.c')
-rw-r--r-- | lib/easy.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/easy.c b/lib/easy.c index 991a25573..b8af38038 100644 --- a/lib/easy.c +++ b/lib/easy.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 @@ -466,13 +466,23 @@ CURLcode curl_easy_perform(CURL *curl) return CURLE_BAD_FUNCTION_ARGUMENT; if( ! (data->share && data->share->hostcache) ) { + /* this handle is not using a shared dns cache */ + + if(data->set.global_dns_cache && + (data->dns.hostcachetype != HCACHE_GLOBAL)) { + /* global dns cache was requested but still isn't */ + struct curl_hash *ptr; - if(Curl_global_host_cache_use(data) && - (data->dns.hostcachetype != HCACHE_GLOBAL)) { if(data->dns.hostcachetype == HCACHE_PRIVATE) + /* if the current cache is private, kill it first */ Curl_hash_destroy(data->dns.hostcache); - data->dns.hostcache = Curl_global_host_cache_get(); - data->dns.hostcachetype = HCACHE_GLOBAL; + + ptr = Curl_global_host_cache_init(); + if(ptr) { + /* only do this if the global cache init works */ + data->dns.hostcache = ptr; + data->dns.hostcachetype = HCACHE_GLOBAL; + } } if(!data->dns.hostcache) { |