From 3788f25eacbf4fcf20b04f1e74ea735b8b9b1396 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 15 Dec 2003 17:33:49 +0000 Subject: added a library-wide interface for doing dns cache pruning, and no longer make the pruning at each name lookup, only in Curl_done(). --- lib/hostip.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'lib/hostip.c') diff --git a/lib/hostip.c b/lib/hostip.c index f2fa350d0..bc0db1925 100644 --- a/lib/hostip.c +++ b/lib/hostip.c @@ -195,6 +195,23 @@ hostcache_prune(curl_hash *hostcache, int cache_timeout, int now) hostcache_timestamp_remove); } +void Curl_hostcache_prune(struct SessionHandle *data) +{ + time_t now; + if(data->share) + Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE); + + time(&now); + + /* Remove outdated and unused entries from the hostcache */ + hostcache_prune(data->hostcache, + data->set.dns_cache_timeout, + now); + + if(data->share) + Curl_share_unlock(data, CURL_LOCK_DATA_DNS); +} + #ifdef HAVE_SIGSETJMP /* Beware this is a global and unique instance */ sigjmp_buf curl_jmpenv; @@ -249,12 +266,6 @@ cache_resolv_response(struct SessionHandle *data, dns->timestamp = now; /* used now */ dns->inuse++; /* mark entry as in-use */ - - /* Remove outdated and unused entries from the hostcache */ - hostcache_prune(data->hostcache, - data->set.dns_cache_timeout, - now); - /* free the allocated entry_id again */ free(entry_id); -- cgit v1.2.3