Daniel Stenberg wrote:
> On Thu, 23 Sep 2004, Bertrand Demiddelaer wrote:
>> Curl_resolv_unlock() is not always called from Curl_done()... btw, I
>> read somewhere it should be called only once per Curl_resolv_lock()
>> call, maybe we should have a look at this ?
> Yes, I smell a problem here. I think the Curl_resolv_unlock() call needs
> to be moved to the curl_disconnect() call so that the DNS entry for the
> host remain locked as long as the connection is still alive and present.
> It feels like that could solve your problem.
> Can you try that simple fix?
Here's a new fix which works for me, and a test program to run with
valgrind... The test 506 is now broken, but I suspect it's a false
positive against the new code (I didn't have time to check it or to
New suggestions welcome !
--- lib/hostip.c.00 Fri Sep 24 18:38:38 2004
+++ lib/hostip.c Fri Sep 24 18:39:23 2004
@@ -459,7 +459,11 @@
+ Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);
dns->inuse++; /* we use it! */
+ Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
rc = CURLRESOLV_RESOLVED;
--- lib/url.c.00 Mon Sep 27 10:41:27 2004
+++ lib/url.c Mon Sep 27 11:01:38 2004
@@ -3228,7 +3228,8 @@
/* re-used connection, no resolving is necessary */
hostaddr = NULL;
- conn->dns_entry = NULL; /* we don't connect now so we don't have any fresh
+ /* We do want to remember conn->dns_entry in order to close it */
+ /* conn->dns_entry = NULL; /* we don't connect now so we don't have any fresh
dns entry struct to point to */
@@ -3478,7 +3479,7 @@
conn->newurl = NULL;
+ if((data->set.reuse_forbid || conn->bits.close) && conn->dns_entry)
Curl_resolv_unlock(conn->data, conn->dns_entry); /* done with this */
#if defined(CURLDEBUG) && defined(AGGRESIVE_TEST)
Received on 2004-09-27
- text/x-csrc attachment: foo.c