Subject: Timeout best practices

Timeout best practices

From: Jakub Hrozek <jhrozek_at_redhat.com>
Date: Wed, 10 Aug 2011 17:27:06 +0200

Hi,

I'd like to ask how other people use c-ares with respect to handling
timeouts.

In general, we would like to tell c-ares "resolve foo.bar and if it
takes more than N seconds, just cancel the request".

Since there is no explicit API to cancel a particular request on-demand
(from our event loop, perhaps), we rely on calling "ares_process_fd(channel,
ARES_SOCKET_BAD, ARES_SOCKET_BAD)" every N seconds, where N is the
value of ARES_OPT_TIMEOUT.

However, this means we need to count the nameservers every time
/etc/resolv.conf is updated (might happen esp. in case of a roaming
laptop) and adjust the ARES_OPT_TIMEOUT value apropriately.

The other way might be to have a single channel per request but that
carries overhead as well..

How are others solving the issue?

Thank you,
    Jakub
Received on 2011-08-10