curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: DNS data not refreshed after CURLOPT_DNS_CACHE_TIMEOUT

From: Narasimha M via curl-library <curl-library_at_cool.haxx.se>
Date: Tue, 1 Sep 2020 12:33:03 +0530

OK. So in the given example from man page, if I add a sleep between two
easy performs, should the application resolve the name?

  ret = curl_easy_perform(curl);
  /* in this second request, the cache will not be used if more than
     two seconds have passed since the previous name resolve */
sleep(5); /* add a sleep of five seconds, so as to force a fresh name
resolve */
  ret = curl_easy_perform(curl);

Thanks,
Narasimha

On Tue, Sep 1, 2020 at 12:11 PM Daniel Stenberg <daniel_at_haxx.se> wrote:

> On Tue, 1 Sep 2020, Narasimha M wrote:
>
> > Hence, I want to keep the connection and handle for a long time. However
> > during this time, there can be changes to the DNS server/data. I would
> like
> > the application to be agnostic to the changes to the DNS. This would
> have
> > been possible if CURL queried the DNS periodically and updated its cache
> for
> > long running handles.
>
> Sure it *could*. It's just code. It could do *anything* if we just add the
> code for it. This feature you're asking for has however not been
> implemented.
>
> > I am still not able to understand the use of CURLOPT_DNS_CACHE_TIMEOUT
> in
> > the context of a given connection which runs for a long time.
>
> curl doesn't resolve the host name AT ALL when it reuses an existing
> connection. It doesn't need to so it avoids it. Saves time and resources.
>
> The DNS cache is only used when a host name is resolved. If no resolving
> is
> done, the DNS cache is not used and therefore the timeout also has no
> meaning.
> The entry is since long removed from the DNS cache but the connection is
> still
> there - and working.
>
> > Could you please point me to any example which can illustrate
> > CURLOPT_DNS_CACHE_TIMEOUT in context of a given curl handle?
>
> How would a cache timeout even get visualized in an example? There's an
> example in the man page for the option:
> https://curl.haxx.se/libcurl/c/CURLOPT_DNS_CACHE_TIMEOUT.html
>
> --
>
> / daniel.haxx.se | Commercial curl support up to 24x7 is available!
> | Private help, bug fixes, support, ports, new features
> | https://www.wolfssl.com/contact/
>

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2020-09-01