]> granicus.if.org Git - curl/commitdiff
Dirk Manske made the share-locking around DNS lookups a bit "looser" so that
authorDaniel Stenberg <daniel@haxx.se>
Sun, 12 Oct 2003 13:57:41 +0000 (13:57 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 12 Oct 2003 13:57:41 +0000 (13:57 +0000)
multiple DNS lookups can run simultaneously faster. The downside is that
resolving the same host name now can be made at once from multiple threads,
but the upside is that threads now don't alwys have to wait for the others'
resolves. Test case 506 updated accordingly.

lib/hostip.c
tests/data/test506

index e82bbe10fceb07769581e00b358cbf7063e4451c..e5363fa8099d1875528500ba30a7651d40a57548 100644 (file)
@@ -307,6 +307,9 @@ int Curl_resolv(struct connectdata *conn,
 
   /* See if its already in our dns cache */
   dns = Curl_hash_pick(data->hostcache, entry_id, entry_len+1);
+  
+  if(data->share)
+    Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
 
   /* free the allocated entry_id again */
   free(entry_id);
@@ -332,12 +335,18 @@ int Curl_resolv(struct connectdata *conn,
       }
     }
     else
+    {
+      if(data->share)
+        Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);
+
       /* we got a response, store it in the cache */
       dns = cache_resolv_response(data, addr, hostname, port);
+      
+      if(data->share)
+        Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
+    }
   }
 
-  if(data->share)
-    Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
 
   *entry = dns;
 
index bb9ee3836a4e1dc3caffc84a5ac3006415a087b0..1fbd4bac80d9caaad341b85e9948c6f5c1b19ea9 100644 (file)
@@ -68,6 +68,8 @@ unlock: share   <Pigs in space>
 PERFORM
 lock:   dns     <Pigs in space>
 unlock: dns     <Pigs in space>
+lock:   dns     <Pigs in space>
+unlock: dns     <Pigs in space>
 lock:   cookie  <Pigs in space>
 unlock: cookie  <Pigs in space>
 lock:   cookie  <Pigs in space>