Subject: What to do when ares_timeout occurs but I don't know on which FD

What to do when ares_timeout occurs but I don't know on which FD

From: Christopher Palow <cpalow_at_facebook.com>
Date: Thu, 12 Jun 2008 14:02:16 -0700

Should I just set the ARES_SOCKET_BAD for the read and write fds to
ares_process_fd when a timeout occurs and I don't know which one timed out?

        /* did we have a c-ares timeout? */
        if(cares_timeout && timercmp(&now, &next_cares_timeout, >))
            ares_process_fd(lookup.conn.ares_chan, ARES_SOCKET_BAD,
ARES_SOCKET_BAD);

Or if going from the sample code with select readers and writers could both
be empty so I'm guessing this is correct but it'd be nice to know for sure.

        if(cares_timeout && timercmp(&now, &next_cares_timeout, >)) {
            fd_set dummy_fd_set;
            FD_ZERO(&dummy_fd_set);
            ares_process(lookup_conn.ares_chan, &dummy_fd_set,
&dummy_fd_set);
        }

Maybe a note to that effect in the man page for ares_timeout?

Thanks,
Chris
Received on 2008-06-12