Unverified Commit f73de32d authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

CURLOPT_DNS_USE_GLOBAL_CACHE: remove

Remove the code too. The functionality has been disabled in code since
7.62.0. Setting this option will from now on simply be ignored and have
no function.

Closes #3654
parent ebc05501
Loading
Loading
Loading
Loading
+0 −20
Original line number Diff line number Diff line
@@ -5,26 +5,6 @@ email the curl-library mailing list as soon as possible and explain to us why
this is a problem for you and how your use case can't be satisfied properly
using a work around.

## `CURLOPT_DNS_USE_GLOBAL_CACHE`

This option makes libcurl use a global non-thread-safe cache for DNS if
enabled. The option has been marked as "obsolete" in the header file and in
documentation for several years already.

There's proper and safe method alternative provided since many years: the
share API.

### State

In curl 7.62.0 setting this option to TRUE will not have any effect. The
global cache will not be enabled. The code still remains so it is easy to
revert if need be.

### Removal

Remove all global-cache related code from curl around April 2019 (might be
7.66.0).

## HTTP/0.9

Supporting this is non-obvious and might even come as a surprise to some
+4 −2
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
.\" *                            | (__| |_| |  _ <| |___
.\" *                             \___|\___/|_| \_\_____|
.\" *
.\" * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" *
.\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms
@@ -29,6 +29,8 @@ CURLOPT_DNS_USE_GLOBAL_CACHE \- enable/disable global DNS cache
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_USE_GLOBAL_CACHE,
                          long enable);
.SH DESCRIPTION
Has no function since 7.62.0. Do note use!

Pass a long. If the \fIenable\fP value is 1, it tells curl to use a global DNS
cache that will survive between easy handle creations and deletions. This is
not thread-safe and this will use a global variable.
@@ -53,7 +55,7 @@ if(curl) {
}
.fi
.SH AVAILABILITY
Subject for removal in the future. Do not use!
Deprecated since 7.62.0. Has no function.
.SH RETURN VALUE
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
.SH "SEE ALSO"
+0 −1
Original line number Diff line number Diff line
@@ -265,7 +265,6 @@ void curl_global_cleanup(void)
  if(--initialized)
    return;

  Curl_global_host_cache_dtor();
  Curl_ssl_cleanup();
  Curl_resolver_global_cleanup();

+0 −34
Original line number Diff line number Diff line
@@ -114,42 +114,8 @@
 * CURLRES_* defines based on the config*.h and curl_setup.h defines.
 */

/* These two symbols are for the global DNS cache */
static struct curl_hash hostname_cache;
static int host_cache_initialized;

static void freednsentry(void *freethis);

/*
 * Curl_global_host_cache_init() initializes and sets up a global DNS cache.
 * Global DNS cache is general badness. Do not use. This will be removed in
 * a future version. Use the share interface instead!
 *
 * Returns a struct curl_hash pointer on success, NULL on failure.
 */
struct curl_hash *Curl_global_host_cache_init(void)
{
  int rc = 0;
  if(!host_cache_initialized) {
    rc = Curl_hash_init(&hostname_cache, 7, Curl_hash_str,
                        Curl_str_key_compare, freednsentry);
    if(!rc)
      host_cache_initialized = 1;
  }
  return rc?NULL:&hostname_cache;
}

/*
 * Destroy and cleanup the global DNS cache
 */
void Curl_global_host_cache_dtor(void)
{
  if(host_cache_initialized) {
    Curl_hash_destroy(&hostname_cache);
    host_cache_initialized = 0;
  }
}

/*
 * Return # of addresses in a Curl_addrinfo struct
 */
+1 −11
Original line number Diff line number Diff line
@@ -402,19 +402,9 @@ CURLMcode curl_multi_add_handle(struct Curl_multi *multi,
  /* set the easy handle */
  multistate(data, CURLM_STATE_INIT);

  if((data->set.global_dns_cache) &&
     (data->dns.hostcachetype != HCACHE_GLOBAL)) {
    /* global dns cache was requested but still isn't */
    struct curl_hash *global = Curl_global_host_cache_init();
    if(global) {
      /* only do this if the global cache init works */
      data->dns.hostcache = global;
      data->dns.hostcachetype = HCACHE_GLOBAL;
    }
  }
  /* for multi interface connections, we share DNS cache automatically if the
     easy handle's one is currently not set. */
  else if(!data->dns.hostcache ||
  if(!data->dns.hostcache ||
     (data->dns.hostcachetype == HCACHE_NONE)) {
    data->dns.hostcache = &multi->hostcache;
    data->dns.hostcachetype = HCACHE_MULTI;
Loading