Subject: Re: c-ares refreshing resolv.conf

Re: c-ares refreshing resolv.conf

From: Dima Tisnek <dimaqq_at_gmail.com>
Date: Wed, 9 Feb 2011 17:35:23 -0700

Moved discussion here from libcurl mailing list.
To recap, I'm planning to add reloading of /etc/resolv.conf et.al.
explicitly, and optionally implicitly at the beginning of new request
if /etc/* was last checked more than new request timeout ago.
c-ares user options are welcome ;-)

TODO already mentions ares_reinit(), so I'll stick with that name.

Looked into the code some, as far as I can understand, a single
channel can be used by a single thread at time and can have multiple
outstanding requests and each request can be in some state among
multiple dns servers. If dns servers/ndots/etc did change, trying to
figure out what to do with each request seems quite hard. I see a few
ways out:
1. mark old data "stale", append new data, garbage collect old data later
2. same as ares_set_servers*() -- but it would assert on outstanding
queries if there are any
3. force ares_cancel() if any server/ndots/env variables/etc changed
-- not great if it's implicit, but if e.g. servers changed
substantially perhaps ok anyway?
4. overwrite data and patch the lookup logic to recheck channel->* on every step

What d'y'all think?

On 8 February 2011 14:11, Daniel Stenberg <daniel_at_haxx.se> wrote:
> On Tue, 8 Feb 2011, Dima Tisnek wrote:
>
>> I think explicit (a)res_init is an ugly hack, in glibc too.
>
> I would rather call it ares_reload() or something...
>
>> If c-ares can only reload dns servers (and other settings) explicitely,
>> then it ought to export all the files (or registry keys) that it may
>> consider. I'm not entirely sure if that's a wise thing to do, as tracking
>> those is an extra dependency for the user.
>>
>> I'll start with explicit reload function, and add a configurable automatic
>> kludge that polls every resolution timeout for now. When that works, it's up
>> to Daniel to include that into trunk or not.
>
> I could see a use for some kind of timeout option that makes c-ares
> automatically reload the data after some kind of timeout or similar.
>
> But really, discussions and patches about possible c-ares improvements and
> features should be taken to the c-ares mailing list instead of here. Believe
> it or not, but c-ares is used by several other softwares than libcurl and
> others may have different ideas and suggestions on this topic!
>
> --
>
>  / daniel.haxx.se
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette:  http://curl.haxx.se/mail/etiquette.html
>
Received on 2011-02-10