Hi,
adig hangs when both ARES_FLAG_USEVC and ARES_FLAG_STAYOPEN
flags are used.
Reason:
Since tcp socket is not closed when all queries are done
ares_fds() functions sets tcp socket to read_fds and returns 1.
So we leave the next loop only if server closes the connection:
/* Wait for all queries to complete. */
while (1)
{
FD_ZERO(&read_fds);
FD_ZERO(&write_fds);
nfds = ares_fds(channel, &read_fds, &write_fds);
if (nfds == 0) {
break;
}
tvp = ares_timeout(channel, NULL, &tv);
count = select(nfds, &read_fds, &write_fds, NULL, tvp);
if (count < 0 && SOCKERRNO != EINVAL)
{
perror("select");
return 1;
}
ares_process(channel, &read_fds, &write_fds);
}
Is there any other way we can be notified that all queries
are done and we can leave the loop?
Thanks,
Alexey Simak
Received on 2009-02-12