diff options
author | Daniel Stenberg <daniel@haxx.se> | 2006-07-07 22:58:06 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2006-07-07 22:58:06 +0000 |
commit | ca319f63ad757a69f14105ab4a8bbf10987b8ad0 (patch) | |
tree | d50690605fefd4ea78795d68068a4425bc9494b2 /lib/hostip.c | |
parent | a09a8164db637b35de52bdea757e8ea930f28eaf (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/hostip.c')
-rw-r--r-- | lib/hostip.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/hostip.c b/lib/hostip.c index ca08524ea..7f071efb2 100644 --- a/lib/hostip.c +++ b/lib/hostip.c @@ -255,7 +255,7 @@ void Curl_hostcache_prune(struct SessionHandle *data) { time_t now; - if((data->set.dns_cache_timeout == -1) || !data->hostcache) + if((data->set.dns_cache_timeout == -1) || !data->dns.hostcache) /* cache forever means never prune, and NULL hostcache means we can't do it */ return; @@ -266,7 +266,7 @@ void Curl_hostcache_prune(struct SessionHandle *data) time(&now); /* Remove outdated and unused entries from the hostcache */ - hostcache_prune(data->hostcache, + hostcache_prune(data->dns.hostcache, data->set.dns_cache_timeout, now); @@ -279,7 +279,7 @@ remove_entry_if_stale(struct SessionHandle *data, struct Curl_dns_entry *dns) { struct hostcache_prune_data user; - if( !dns || (data->set.dns_cache_timeout == -1) || !data->hostcache) + if( !dns || (data->set.dns_cache_timeout == -1) || !data->dns.hostcache) /* cache forever means never prune, and NULL hostcache means we can't do it */ return 0; @@ -296,7 +296,7 @@ remove_entry_if_stale(struct SessionHandle *data, struct Curl_dns_entry *dns) if(data->share) Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE); - Curl_hash_clean_with_criterium(data->hostcache, + Curl_hash_clean_with_criterium(data->dns.hostcache, (void *) &user, hostcache_timestamp_remove); @@ -356,7 +356,8 @@ Curl_cache_addr(struct SessionHandle *data, /* Store the resolved data in our DNS cache. This function may return a pointer to an existing struct already present in the hash, and it may return the same argument we pass in. Make no assumptions. */ - dns2 = Curl_hash_add(data->hostcache, entry_id, entry_len+1, (void *)dns); + dns2 = Curl_hash_add(data->dns.hostcache, entry_id, entry_len+1, + (void *)dns); if(!dns2) { /* Major badness, run away. */ free(dns); @@ -428,7 +429,7 @@ int Curl_resolv(struct connectdata *conn, Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE); /* See if its already in our dns cache */ - dns = Curl_hash_pick(data->hostcache, entry_id, entry_len+1); + dns = Curl_hash_pick(data->dns.hostcache, entry_id, entry_len+1); if(data->share) Curl_share_unlock(data, CURL_LOCK_DATA_DNS); |