Donate Share

curl and libcurl

Tracker: Bugs

6 DNS cache - outstanding references can prevent timeout - ID: 2891595
Last Update: Settings changed ( bagder )

Heavy use of a DNS entry by multiple threads can prevent it from being ejected from the cache, even after its timeout has been exceeded. This patch attached fixes this issue.

The patch allows a DNS entry to persist outside of the hash cache and be released when the last connection referencing it calls Curl_resolv_unlock.
It also changes the hash abstraction to replace an entry with a new one by default rather than favoring older entries. I checked the other use of the hash abstraction in multi.c and it already assumes that the insert will either succeed or return NULL -- not that it will return the old element.

I've also added some debugging code that helps catch reference leaks. After curl_easy_cleanup() is called on all extant handles, curl_get_ndns() should return 0.




Constantine Sapuntzakis ( csapuntz ) - 2009-11-04 01:07:44 UTC

6

Closed

Accepted

Daniel Stenberg

name resolving/DNS

bad behaviour

Public


Comments ( 3 )

Date: 2009-11-11 09:32:18 UTC
Sender: bagderProject AdminAccepting Donations

Thanks for the report, this problem is now fixed in CVS!


Date: 2009-11-07 00:34:03 UTC
Sender: csapuntz

New version of patch should address your concerns. Some more code cleanup
too.



Date: 2009-11-06 22:29:31 UTC
Sender: bagderProject AdminAccepting Donations

Thanks a lot. This seems like a good idea.

Two things on the patch, one question and one request:

Question: In the function Curl_resolv_unlock() the free functions are only
called in inuse is zero AND timestamp is zero. What is the rationale for
checking the timestamp? If it reaches zero uses, why can't it be freed
unregarding of what the time stamp field says? I think it would be suitable
with a comment in the code explaining that, since it is certainly not clear
to me!

Request: the 'ndns' variable looks handy for debugging, but it should then
only be included when a debug build is actually made. Use #ifdef CURLDEBUF
and DEBUGF(ndns++); etc.


Attached Files ( 2 )

Filename Description Download
dns-cache.diff Patch to fix problem Download
dns-cache2.diff Improved comments Download

Changes ( 7 )

Field Old Value Date By
status_id Open 2009-11-11 09:32:19 UTC bagder
resolution_id None 2009-11-11 09:32:19 UTC bagder
allow_comments 1 2009-11-11 09:32:19 UTC bagder
close_date - 2009-11-11 09:32:19 UTC bagder
File Added 349862: dns-cache2.diff 2009-11-07 00:32:13 UTC csapuntz
priority 5 2009-11-06 22:29:32 UTC bagder
File Added 349443: dns-cache.diff 2009-11-04 01:07:46 UTC csapuntz