diff options
author | Daniel Stenberg <daniel@haxx.se> | 2003-10-12 13:57:41 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2003-10-12 13:57:41 +0000 |
commit | 022996e5c77e4a1bdf43f17a3562efee314478c3 (patch) | |
tree | 180882201ae19d1c125e3631cd1df754fadf2411 /lib | |
parent | 4935853eb9d13beba2fa9ba1702b69fdb71832cc (diff) |
Dirk Manske made the share-locking around DNS lookups a bit "looser" so that
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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/hostip.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/hostip.c b/lib/hostip.c index e82bbe10f..e5363fa80 100644 --- a/lib/hostip.c +++ b/lib/hostip.c @@ -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; |