Esempio n. 1
0
static int
remove_entry_if_stale(struct SessionHandle *data, struct Curl_dns_entry *dns)
{
  struct hostcache_prune_data user;

  if( !dns || (data->set.dns_cache_timeout == -1) || !data->hostcache)
    /* cache forever means never prune, and NULL hostcache means
       we can't do it */
    return 0;

  time(&user.now);
  user.cache_timeout = data->set.dns_cache_timeout;

  if ( !hostcache_timestamp_remove(&user,dns) )
    return 0;

  /* ok, we do need to clear the cache. although we need to remove just a
     single entry we clean the entire hash, as no explicit delete function
     is provided */
  if(data->share)
    Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);

  Curl_hash_clean_with_criterium(data->hostcache,
                                 (void *) &user,
                                 hostcache_timestamp_remove);

  if(data->share)
    Curl_share_unlock(data, CURL_LOCK_DATA_DNS);

  return 1;
}
Esempio n. 2
0
void Curl_hostcache_clean(struct SessionHandle *data)
{
  /* Entries added to the hostcache with the CURLOPT_RESOLVE function are
   * still present in the cache with the inuse counter set to 1. Detect them
   * and cleanup!
   */
  Curl_hash_clean_with_criterium(data->dns.hostcache, data, hostcache_inuse);
}
Esempio n. 3
0
/*
 * Prune the DNS cache. This assumes that a lock has already been taken.
 */
static void
hostcache_prune( curl_hash *hostcache, int cache_timeout, time_t now ) {
	struct hostcache_prune_data user;

	user.cache_timeout = cache_timeout;
	user.now = now;

	Curl_hash_clean_with_criterium( hostcache,
									(void *) &user,
									hostcache_timestamp_remove );
}
Esempio n. 4
0
/*
 * Check if the entry should be pruned. Assumes a locked cache.
 */
static int
remove_entry_if_stale(struct SessionHandle *data, struct Curl_dns_entry *dns)
{
  struct hostcache_prune_data user;

  if( !dns || (data->set.dns_cache_timeout == -1) || !data->dns.hostcache)
    /* cache forever means never prune, and NULL hostcache means
       we can't do it */
    return 0;

  time(&user.now);
  user.cache_timeout = data->set.dns_cache_timeout;

  if( !hostcache_timestamp_remove(&user,dns) )
    return 0;

  Curl_hash_clean_with_criterium(data->dns.hostcache,
                                 (void *) &user,
                                 hostcache_timestamp_remove);

  return 1;
}
Esempio n. 5
0
File: hash.c Progetto: AndyUI/curl
/* Removes all the entries in the given hash.
 *
 * @unittest: 1602
 */
void
Curl_hash_clean(struct curl_hash *h)
{
  Curl_hash_clean_with_criterium(h, NULL, NULL);
}