{"action":"created","issue":{"url":"https://api.github.com/repos/bagder/curl/issues/403","labels_url":"https://api.github.com/repos/bagder/curl/issues/403/labels{/name}","comments_url":"https://api.github.com/repos/bagder/curl/issues/403/comments","events_url":"https://api.github.com/repos/bagder/curl/issues/403/events","html_url":"https://github.com/bagder/curl/pull/403","id":103768510,"number":403,"title":"Close connection when DNS entry is removed from cache","user":{"login":"mjcdiggity","id":1402084,"avatar_url":"https://avatars.githubusercontent.com/u/1402084?v=3","gravatar_id":"","url":"https://api.github.com/users/mjcdiggity","html_url":"https://github.com/mjcdiggity","followers_url":"https://api.github.com/users/mjcdiggity/followers","following_url":"https://api.github.com/users/mjcdiggity/following{/other_user}","gists_url":"https://api.github.com/users/mjcdiggity/gists{/gist_id}","starred_url":"https://api.github.com/users/mjcdiggity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjcdiggity/subscriptions","organizations_url":"https://api.github.com/users/mjcdiggity/orgs","repos_url":"https://api.github.com/users/mjcdiggity/repos","events_url":"https://api.github.com/users/mjcdiggity/events{/privacy}","received_events_url":"https://api.github.com/users/mjcdiggity/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-08-28T18:07:17Z","updated_at":"2015-08-31T20:10:34Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/bagder/curl/pulls/403","html_url":"https://github.com/bagder/curl/pull/403","diff_url":"https://github.com/bagder/curl/pull/403.diff","patch_url":"https://github.com/bagder/curl/pull/403.patch"},"body":"There are two fixes in this PR:\r\n\r\n1) DNS_CACHE_TIMEOUT is not respected\r\n\r\nWe ran across an issue where DNS cache entry were never removed for reused connections, and this is fixed by commented out the if block in `resolve_server` in `multi.c`. This would cause DNS entries to be zapped, while still reusing the connection. The fix is only temporary and will be replaced with an appropriate check/fix.\r\n\r\n2) Existing connections would not re-resolve DNS, even after cache has been cleared\r\n\r\nRelated to the previous fix, our solution was to mark the connection for closing when the DNS entry was cleared from the cache. Cache clear does not alter the current connection, and only closing the connection would force DNS resolution (by creating a new connection). This is more efficient than creating a new connection per request via the `CURL_FRESH_CONNECT`option.\r\n\r\nThis is a work in progress, and just wanted to get feedback on proposed changes. Will add tests/comments/whatever if necessary for merging it into mainline. I will also clean up the commits before merging. \r\n\r\nThanks. "},"comment":{"url":"https://api.github.com/repos/bagder/curl/issues/comments/136485777","html_url":"https://github.com/bagder/curl/pull/403#issuecomment-136485777","issue_url":"https://api.github.com/repos/bagder/curl/issues/403","id":136485777,"user":{"login":"mjcdiggity","id":1402084,"avatar_url":"https://avatars.githubusercontent.com/u/1402084?v=3","gravatar_id":"","url":"https://api.github.com/users/mjcdiggity","html_url":"https://github.com/mjcdiggity","followers_url":"https://api.github.com/users/mjcdiggity/followers","following_url":"https://api.github.com/users/mjcdiggity/following{/other_user}","gists_url":"https://api.github.com/users/mjcdiggity/gists{/gist_id}","starred_url":"https://api.github.com/users/mjcdiggity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjcdiggity/subscriptions","organizations_url":"https://api.github.com/users/mjcdiggity/orgs","repos_url":"https://api.github.com/users/mjcdiggity/repos","events_url":"https://api.github.com/users/mjcdiggity/events{/privacy}","received_events_url":"https://api.github.com/users/mjcdiggity/received_events","type":"User","site_admin":false},"created_at":"2015-08-31T20:10:34Z","updated_at":"2015-08-31T20:10:34Z","body":"This PR has been cleaned up, and I believe the desired functionality is more clear. The changes are described in the commit message, but basically an option has been added, CURLOPT_DNS_CACHE_CLOSE_CONNECTION, which if set will close the connection on DNS cache purge. In addition, CURLOPT_DNS_CACHE_TIMEOUT is checked in url.c resolve_server() to see if DNS cache timeout should be considered. This is the case when DNS_CACHE_TIMEOUT is not -1, and thus the cache is used with timeouts. "}}