On Tue, 4 Sep 2007, Uli wrote:
> If I want to use epoll() I call epoll_ctl(fd, EPOLL_CTL_ADD,...); for each
> socket I created once and don't have to bother about it again. The problem
> now is that I don't have a way to do this for c-ares as I only can get a
> complete list of sockets it's interested in.
But why would you be interested in other sockets than exactly those that
c-ares says it is using right now?
> So now my idea was to use ares_getsock() to get a list of sockets, add each
> with epoll_ctl() (which is one syscall per socket :/) and remove them after
> epoll_wait(), because else I get EEXIST when I add them again on the next
> loop.
So, don't remove them until you in the next loop check again which sockets it
uses and then only remove those that c-ares no longer uses.
> The right way in this case would be EPOLL_CTL_MOD if I want to change
> ev.events (read / write / out-of-band-data).
Yes, you need to do that on the sockets that have changed mode between the
invokes.
> Since this would need much state-tracking I instead remove the sockets
> afterwards again.
Right, but then that is your choice and in fact not forced by the c-ares API.
> I hope to have made my problem clearer and I'm sorry but I have no idea for
> a nice API-call to handle this. Perhaps some call backs for when a socket is
> created / removed / it changes if c-ares wants to read/write from it?
Yes, a callback system would be much nicer and that's how we do it in
libcurl... Feel free to work on such an implementation for c-ares. I believe
there was such a patch posted in the past, but I'm not sure how good it was or
anything. I have a hard time to find gaps to spend time on c-ares.
-- c-ares -- my preferred DNS asynch resolver libraryReceived on 2007-09-05