diff options
author | Jason Glasgow <jglasgow@chromium.org> | 2011-11-30 15:23:44 -0500 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2011-12-02 10:18:52 +0100 |
commit | adc88ca203bbb602cc9a1726669526fa7b3723ef (patch) | |
tree | ee204bc5025ed66554ca1cfbbea4637ec64cf14a /lib/asyn-ares.c | |
parent | 83350c9cc407d8292e9576991f23415c6ad1a021 (diff) | |
download | curl-adc88ca203bbb602cc9a1726669526fa7b3723ef.tar.gz |
multi: handle timeouts on DNS servers by checking for new sockets
If the first name server is not available, the multi interface does
not invoke the socket_cb when the DNS request to the first name server
timesout. Ensure that the list of sockets are always updated after
calling Curl_resolver_is_resolved.
This bug can be reproduced if Curl is complied with --enable_ares and
your code uses the multi socket interfaces and the
CURLMOPT_SOCKETFUNCTION option. To test try:
iptables -I INPUT \
-s $(sed -n -e '/name/{s/.* //p;q}' /etc/resolv.conf)/32 \
-j REJECT
and then run a program which uses the multi-interface.
Diffstat (limited to 'lib/asyn-ares.c')
-rw-r--r-- | lib/asyn-ares.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c index 7c2c372c3..0b454849d 100644 --- a/lib/asyn-ares.c +++ b/lib/asyn-ares.c @@ -227,18 +227,19 @@ int Curl_resolver_getsock(struct connectdata *conn, struct timeval maxtime; struct timeval timebuf; struct timeval *timeout; + long milli; int max = ares_getsock((ares_channel)conn->data->state.resolver, (ares_socket_t *)socks, numsocks); - maxtime.tv_sec = CURL_TIMEOUT_RESOLVE; maxtime.tv_usec = 0; timeout = ares_timeout((ares_channel)conn->data->state.resolver, &maxtime, &timebuf); - - Curl_expire(conn->data, - (timeout->tv_sec * 1000) + (timeout->tv_usec/1000)); + milli = (timeout->tv_sec * 1000) + (timeout->tv_usec/1000); + if(milli == 0) + milli += 10; + Curl_expire(conn->data, milli); return max; } |