]> granicus.if.org Git - curl/commitdiff
Mark the dns entry 'inuse' properly even when used from the cache. This
authorDaniel Stenberg <daniel@haxx.se>
Sun, 15 Feb 2004 16:57:53 +0000 (16:57 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 15 Feb 2004 16:57:53 +0000 (16:57 +0000)
seems to correct some host cache screw-ups I could reproduce.

lib/hostip.c

index 3e219612044b0bb535060f561489f68abe12773e..f1583eaed7b54ed627d594e9d46048a5a2970c8f 100644 (file)
@@ -191,7 +191,7 @@ hostcache_prune(curl_hash *hostcache, int cache_timeout, int now)
 
   user.cache_timeout = cache_timeout;
   user.now = now;
-  
+
   Curl_hash_clean_with_criterium(hostcache, 
                                  (void *) &user, 
                                  hostcache_timestamp_remove);
@@ -367,8 +367,10 @@ int Curl_resolv(struct connectdata *conn,
         rc = 0;
     }
   }
-  else
+  else {
+    dns->inuse++; /* we use it! */
     rc = 0;
+  }
 
   *entry = dns;
 
@@ -382,9 +384,15 @@ void Curl_resolv_unlock(struct SessionHandle *data, struct Curl_dns_entry *dns)
 
   dns->inuse--;
 
+#ifdef CURLDEBUG
+  if(dns->inuse < 0) {
+    infof(data, "Interal host cache screw-up!");
+    *(char **)0=NULL;
+  }
+#endif
+
   if(data->share)
     Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
-
 }
 
 /*