On Wed, Jan 18, 2006 at 09:48:02AM +0100, Daniel Stenberg wrote:
> On Tue, 17 Jan 2006, William Ahern wrote:
>
> >The timeout is relative to the logical query, not to each server. So that,
> >if you pass a query timeout of 10 seconds, but the ares channel is
> >configured for a server timeout of 3 seconds, a try count of 2, and 2
> >hosts in resolv.conf you'd actually be cutting short the query by 2
> >seconds (from 12 to 10).
>
> It certainly sounds like a fair feature to add. Any idea on how it could be
> done public API-wise?
Well, sometimes I use a neat hack to add optional final arguments to
functions, but it requires C99's __VA_ARGS__. Actually, I find it somewhat
elegant when used purposefully, like in this case. And of course, when the
routine isn't expected to be taken as a pointer, at which point macro magic
becomes an offense punishable by death.
Basically, it would look like this:
ares_gethostbyname(ares_channel channel, const char *name, int family,
ares_host_callback cb, void *arg, int nsec, ...)
#ifndef ARES_INTERNAL_API
#define ares_gethostbyname(...) ares_gethostbyname(__VA_ARGS__,0)
#endif
Then, it remains backwards source compatible. If the timeout argument is
actually used the additional `0' we tack on falls into var args land.
There's even more we could do with C99 and anonymous compound literals ;)
But I've probably used up all my karma for the day.
I wouldn't mind an ares_gethostbyname_?? variant. Or, we could just not
worry about it and wait for or design a better alternative interface for
Ares. The old-style IPv4-era look-alike interfaces have other irredeemable
qualities.
- Bill
Received on Wed Jan 18 22:48:57 2006