aboutsummaryrefslogtreecommitdiff
path: root/lib/easy.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2006-07-07 22:58:06 +0000
committerDaniel Stenberg <daniel@haxx.se>2006-07-07 22:58:06 +0000
commitca319f63ad757a69f14105ab4a8bbf10987b8ad0 (patch)
treed50690605fefd4ea78795d68068a4425bc9494b2 /lib/easy.c
parenta09a8164db637b35de52bdea757e8ea930f28eaf (diff)
Ingmar Runge provided a source snippet that caused a crash. The reason for
the crash was that libcurl internally was a bit confused about who owned the DNS cache at all times so if you created an easy handle that uses a shared DNS cache and added that to a multi handle it would crash. Now we keep more careful internal track of exactly what kind of DNS cache each easy handle uses: None, Private (allocated for and used only by this single handle), Shared (points to a cache held by a shared object), Global (points to the global cache) or Multi (points to the cache within the multi handle that is automatically shared between all easy handles that are added with private caches).
Diffstat (limited to 'lib/easy.c')
-rw-r--r--lib/easy.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/easy.c b/lib/easy.c
index fdbb6a0e2..2784db83f 100644
--- a/lib/easy.c
+++ b/lib/easy.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2006, 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
@@ -436,16 +436,18 @@ CURLcode curl_easy_perform(CURL *curl)
if ( ! (data->share && data->share->hostcache) ) {
if (Curl_global_host_cache_use(data) &&
- data->hostcache != Curl_global_host_cache_get()) {
- if (data->hostcache)
- Curl_hash_destroy(data->hostcache);
- data->hostcache = Curl_global_host_cache_get();
+ (data->dns.hostcachetype != HCACHE_GLOBAL)) {
+ if (data->dns.hostcachetype == HCACHE_PRIVATE)
+ Curl_hash_destroy(data->dns.hostcache);
+ data->dns.hostcache = Curl_global_host_cache_get();
+ data->dns.hostcachetype = HCACHE_GLOBAL;
}
- if (!data->hostcache) {
- data->hostcache = Curl_mk_dnscache();
+ if (!data->dns.hostcache) {
+ data->dns.hostcachetype = HCACHE_PRIVATE;
+ data->dns.hostcache = Curl_mk_dnscache();
- if(!data->hostcache)
+ if(!data->dns.hostcache)
/* While we possibly could survive and do good without a host cache,
the fact that creating it failed indicates that things are truly
screwed up and we should bail out! */