]> granicus.if.org Git - curl/commitdiff
fix bug (?) :-)
authorSterling Hughes <sterling@bumblebury.com>
Mon, 6 Jan 2003 06:17:15 +0000 (06:17 +0000)
committerSterling Hughes <sterling@bumblebury.com>
Mon, 6 Jan 2003 06:17:15 +0000 (06:17 +0000)
previously, if you called curl_easy_perform and then set the global dns
cache, the global cache wouldn't be used.  I don't see this really happening
in practice, but this code allows you to do it.

lib/easy.c

index a068604b472e22a33d006a3696ece163a682ab91..145db5af15f09aa51eec0700c70291f0941f5470 100644 (file)
@@ -233,15 +233,17 @@ CURLcode curl_easy_perform(CURL *curl)
 {
   struct SessionHandle *data = (struct SessionHandle *)curl;
 
-  if (!data->hostcache) {
-    if (Curl_global_host_cache_use(data)) {
-      data->hostcache = Curl_global_host_cache_get();
-    }
-    else {
-      data->hostcache = Curl_hash_alloc(7, Curl_freednsinfo);
+  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();
   }
 
+  if (!data->hostcache) {
+    data->hostcache = Curl_hash_alloc(7, Curl_freednsinfo);
+  }
+  
   return Curl_perform(data);
 }