aboutsummaryrefslogtreecommitdiff
path: root/lib/url.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/url.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/url.c')
-rw-r--r--lib/url.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/url.c b/lib/url.c
index 85537b2ce..6e50e7a03 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -205,7 +205,7 @@ CURLcode Curl_close(struct SessionHandle *data)
if ( ! (data->share && data->share->hostcache) ) {
if ( !Curl_global_host_cache_use(data)) {
- Curl_hash_destroy(data->hostcache);
+ Curl_hash_destroy(data->dns.hostcache);
}
}
@@ -1392,8 +1392,10 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
if(data->share) {
Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE);
- if(data->share->hostcache == data->hostcache)
- data->hostcache = NULL;
+ if(data->dns.hostcachetype == HCACHE_SHARED) {
+ data->dns.hostcache = NULL;
+ data->dns.hostcachetype = HCACHE_NONE;
+ }
if(data->share->cookies == data->cookies)
data->cookies = NULL;
@@ -1413,11 +1415,12 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
data->share->dirty++;
if(data->share->hostcache) {
- /* use shared host cache, first free own one if any */
- if(data->hostcache)
- Curl_hash_destroy(data->hostcache);
+ /* use shared host cache, first free the private one if any */
+ if(data->dns.hostcachetype == HCACHE_PRIVATE)
+ Curl_hash_destroy(data->dns.hostcache);
- data->hostcache = data->share->hostcache;
+ data->dns.hostcache = data->share->hostcache;
+ data->dns.hostcachetype = HCACHE_SHARED;
}
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
if(data->share->cookies) {